/Docs/07-Implementacion/Source/trunk/EDUAR_actual/EDUAR/EDUAR_BusinessLogic/Common/BLCicloLectivo.cs

http://blpm.googlecode.com/ · C# · 299 lines · 233 code · 19 blank · 47 comment · 12 complexity · 6af52cf2a62aa42a5f9d3204a2619e7c MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EDUAR_DataAccess.Common;
  6. using EDUAR_Entities;
  7. using EDUAR_BusinessLogic.Shared;
  8. using EDUAR_Entities.Shared;
  9. using EDUAR_Utility.Excepciones;
  10. using EDUAR_Utility.Enumeraciones;
  11. using EDUAR_DataAccess.Shared;
  12. namespace EDUAR_BusinessLogic.Common
  13. {
  14. public class BLCicloLectivo : BusinessLogicBase<CicloLectivo, DACicloLectivo>
  15. {
  16. #region --[Constante]--
  17. private const string ClassName = "BLCicloLectivo";
  18. #endregion
  19. #region --[Constructores]--
  20. /// <summary>
  21. /// Constructor con DTO como parámetro.
  22. /// </summary>
  23. public BLCicloLectivo(DTBase objCicloLectivo)
  24. {
  25. Data = (CicloLectivo)objCicloLectivo;
  26. }
  27. /// <summary>
  28. /// Constructor vacio
  29. /// </summary>
  30. public BLCicloLectivo()
  31. {
  32. Data = new CicloLectivo();
  33. }
  34. #endregion
  35. #region --[Propiedades Override]--
  36. protected override sealed DACicloLectivo DataAcces
  37. {
  38. get { return dataAcces; }
  39. set { dataAcces = value; }
  40. }
  41. public override sealed CicloLectivo Data
  42. {
  43. get { return data; }
  44. set { data = value; }
  45. }
  46. public override string FieldId
  47. {
  48. get { return DataAcces.FieldID; }
  49. }
  50. public override string FieldDescription
  51. {
  52. get { return DataAcces.FieldDescription; }
  53. }
  54. /// <summary>
  55. /// Gets the by id.
  56. /// </summary>
  57. public override void GetById()
  58. {
  59. try
  60. {
  61. Data = DataAcces.GetById(Data);
  62. }
  63. catch (CustomizedException ex)
  64. {
  65. throw ex;
  66. }
  67. catch (Exception ex)
  68. {
  69. throw new CustomizedException(string.Format("Fallo en {0} - GetById", ClassName), ex,
  70. enuExceptionType.BusinessLogicException);
  71. }
  72. }
  73. /// <summary>
  74. /// Método que guarda el registro actualmente cargado en memoria. No importa si se trata de una alta o modificación.
  75. /// </summary>
  76. public override void Save()
  77. {
  78. try
  79. {
  80. //Abre la transaccion que se va a utilizar
  81. DataAcces.Transaction.OpenTransaction();
  82. int idCicloLectivo = 0;
  83. if (Data.idCicloLectivo == 0)
  84. DataAcces.Create(Data, out idCicloLectivo);
  85. else
  86. DataAcces.Update(Data);
  87. //Se da el OK para la transaccion.
  88. DataAcces.Transaction.CommitTransaction();
  89. }
  90. catch (CustomizedException ex)
  91. {
  92. if (DataAcces != null && DataAcces.Transaction != null)
  93. DataAcces.Transaction.RollbackTransaction();
  94. throw ex;
  95. }
  96. catch (Exception ex)
  97. {
  98. if (DataAcces != null && DataAcces.Transaction != null)
  99. DataAcces.Transaction.RollbackTransaction();
  100. throw new CustomizedException(string.Format("Fallo en {0} - Save()", ClassName), ex,
  101. enuExceptionType.BusinessLogicException);
  102. }
  103. }
  104. /// <summary>
  105. /// Método que guarda el registro actualmente cargado en memoria. No importa si se trata de una alta o modificación.
  106. /// </summary>
  107. public override void Save(DATransaction objDATransaction)
  108. {
  109. try
  110. {
  111. //Si no viene el Id es porque se esta creando la entidad
  112. DataAcces = new DACicloLectivo(objDATransaction);
  113. if (Data.idCicloLectivo == 0)
  114. DataAcces.Create(Data);
  115. else
  116. {
  117. DataAcces.Update(Data);
  118. }
  119. }
  120. catch (CustomizedException ex)
  121. {
  122. throw ex;
  123. }
  124. catch (Exception ex)
  125. {
  126. throw new CustomizedException(string.Format("Fallo en {0} - Save()", ClassName), ex,
  127. enuExceptionType.BusinessLogicException);
  128. }
  129. }
  130. public override void Delete()
  131. {
  132. throw new NotImplementedException();
  133. }
  134. public override void Delete(DATransaction objDATransaction)
  135. {
  136. try
  137. {
  138. DataAcces = new DACicloLectivo(objDATransaction);
  139. DataAcces.Delete(Data);
  140. }
  141. catch (CustomizedException ex)
  142. {
  143. throw ex;
  144. }
  145. catch (Exception ex)
  146. {
  147. throw new CustomizedException(string.Format("Fallo en {0} - Delete()", ClassName), ex,
  148. enuExceptionType.BusinessLogicException);
  149. }
  150. }
  151. #endregion
  152. #region --[Métodos publicos]--
  153. /// <summary>
  154. /// Gets the ciclo lectivos.
  155. /// </summary>
  156. /// <param name="entidad">The entidad.</param>
  157. /// <returns></returns>
  158. public List<CicloLectivo> GetCicloLectivos(CicloLectivo entidad)
  159. {
  160. try
  161. {
  162. return DataAcces.GetCicloLectivos(entidad);
  163. }
  164. catch (CustomizedException ex)
  165. {
  166. throw ex;
  167. }
  168. catch (Exception ex)
  169. {
  170. throw new CustomizedException(string.Format("Fallo en {0} - GetCicloLectivos", ClassName), ex,
  171. enuExceptionType.BusinessLogicException);
  172. }
  173. }
  174. /// <summary>
  175. /// Gets the cursos por ciclo lectivo.
  176. /// </summary>
  177. /// <param name="entidad">The entidad.</param>
  178. /// <returns></returns>
  179. public List<Curso> GetCursosByCicloLectivo(int idCicloLectivo)
  180. {
  181. try
  182. {
  183. return DataAcces.GetCursosByAsignatura(new Asignatura { curso = new Curso { cicloLectivo = new CicloLectivo { idCicloLectivo = idCicloLectivo } } });
  184. }
  185. catch (CustomizedException ex)
  186. {
  187. throw ex;
  188. }
  189. catch (Exception ex)
  190. {
  191. throw new CustomizedException(string.Format("Fallo en {0} - GetCursosByCicloLectivo", ClassName), ex,
  192. enuExceptionType.BusinessLogicException);
  193. }
  194. }
  195. /// <summary>
  196. /// Gets the periodos.
  197. /// </summary>
  198. /// <param name="entidad">The entidad.</param>
  199. /// <returns></returns>
  200. public List<Periodo> GetPeriodosByCicloLectivo(int idCicloLectivo)
  201. {
  202. try
  203. {
  204. return DataAcces.GetPeriodosByCicloLectivo(idCicloLectivo);
  205. }
  206. catch (CustomizedException ex)
  207. {
  208. throw ex;
  209. }
  210. catch (Exception ex)
  211. {
  212. throw new CustomizedException(string.Format("Fallo en {0} - GetPeriodosByCicloLectivo", ClassName), ex,
  213. enuExceptionType.BusinessLogicException);
  214. }
  215. }
  216. /// <summary>
  217. /// Gets the cursos by docente.
  218. /// </summary>
  219. /// <param name="entidad">The entidad.</param>
  220. /// <returns></returns>
  221. public List<Curso> GetCursosByAsignatura(Asignatura entidad)
  222. {
  223. try
  224. {
  225. return DataAcces.GetCursosByAsignatura(entidad);
  226. }
  227. catch (CustomizedException ex)
  228. {
  229. throw ex;
  230. }
  231. catch (Exception ex)
  232. {
  233. throw new CustomizedException(string.Format("Fallo en {0} - GetCursosByAsignatura", ClassName), ex,
  234. enuExceptionType.BusinessLogicException);
  235. }
  236. }
  237. /// <summary>
  238. /// Gets the cursos by ciclo lectivo.
  239. /// </summary>
  240. /// <param name="entidad">The entidad.</param>
  241. /// <returns></returns>
  242. public List<Curso> GetCursosByCicloLectivo(Curso entidad)
  243. {
  244. try
  245. {
  246. return DataAcces.GetCursosByCicloLectivo(entidad);
  247. }
  248. catch (CustomizedException ex)
  249. {
  250. throw ex;
  251. }
  252. catch (Exception ex)
  253. {
  254. throw new CustomizedException(string.Format("Fallo en {0} - GetCursosByCicloLectivo", ClassName), ex,
  255. enuExceptionType.BusinessLogicException);
  256. }
  257. }
  258. /// <summary>
  259. /// Gets the ciclo lectivo actual.
  260. /// </summary>
  261. /// <returns></returns>
  262. public CicloLectivo GetCicloLectivoActual()
  263. {
  264. try
  265. {
  266. return DataAcces.GetCicloLectivoActual();
  267. }
  268. catch (CustomizedException ex)
  269. {
  270. throw ex;
  271. }
  272. catch (Exception ex)
  273. {
  274. throw new CustomizedException(string.Format("Fallo en {0} - GetCicloLectivos", ClassName), ex,
  275. enuExceptionType.BusinessLogicException);
  276. }
  277. }
  278. #endregion
  279. }
  280. }