/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR/EDUAR_BusinessLogic/Common/BLAsignatura.cs

http://blpm.googlecode.com/ · C# · 252 lines · 197 code · 17 blank · 38 comment · 4 complexity · 44de4d9c7b7f07903277e9e189bd1944 MD5 · raw file

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