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

http://blpm.googlecode.com/ · C# · 183 lines · 151 code · 14 blank · 18 comment · 12 complexity · ba24ab3cfabf7c0bb5b9efd1176856fb 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 BLReunion : BusinessLogicBase<Reunion, DAReunion>
  13. {
  14. #region --[Constante]--
  15. private const string ClassName = "BLReunion";
  16. #endregion
  17. #region --[Constructores]--
  18. /// <summary>
  19. /// Constructor con DTO como parámetro.
  20. /// </summary>
  21. public BLReunion(DTBase objReunion)
  22. {
  23. Data = (Reunion)objReunion;
  24. }
  25. /// <summary>
  26. /// Constructor vacio
  27. /// </summary>
  28. public BLReunion()
  29. {
  30. Data = new Reunion();
  31. }
  32. #endregion
  33. #region --[Propiedades Override]--
  34. protected override sealed DAReunion DataAcces
  35. {
  36. get { return dataAcces; }
  37. set { dataAcces = value; }
  38. }
  39. public override sealed Reunion 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 idReunion = 0;
  81. if (Data.idReunion == 0)
  82. DataAcces.Create(Data, out idReunion);
  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. if (DataAcces != null && DataAcces.Transaction != null)
  91. DataAcces.Transaction.RollbackTransaction();
  92. throw ex;
  93. }
  94. catch (Exception ex)
  95. {
  96. if (DataAcces != null && DataAcces.Transaction != null)
  97. DataAcces.Transaction.RollbackTransaction();
  98. throw new CustomizedException(string.Format("Fallo en {0} - Save()", ClassName), ex,
  99. enuExceptionType.BusinessLogicException);
  100. }
  101. }
  102. /// <summary>
  103. /// Método que guarda el registro actualmente cargado en memoria. No importa si se trata de una alta o modificación.
  104. /// </summary>
  105. public override void Save(DATransaction objDATransaction)
  106. {
  107. try
  108. {
  109. //Si no viene el Id es porque se esta creando la entidad
  110. DataAcces = new DAReunion(objDATransaction);
  111. if (Data.idReunion == 0)
  112. DataAcces.Create(Data);
  113. else
  114. {
  115. DataAcces.Update(Data);
  116. }
  117. }
  118. catch (CustomizedException ex)
  119. {
  120. throw ex;
  121. }
  122. catch (Exception ex)
  123. {
  124. throw new CustomizedException(string.Format("Fallo en {0} - Save()", ClassName), ex,
  125. enuExceptionType.BusinessLogicException);
  126. }
  127. }
  128. public override void Delete()
  129. {
  130. throw new NotImplementedException();
  131. }
  132. public override void Delete(DATransaction objDATransaction)
  133. {
  134. try
  135. {
  136. DataAcces = new DAReunion(objDATransaction);
  137. DataAcces.Delete(Data);
  138. }
  139. catch (CustomizedException ex)
  140. {
  141. throw ex;
  142. }
  143. catch (Exception ex)
  144. {
  145. throw new CustomizedException(string.Format("Fallo en {0} - Delete()", ClassName), ex,
  146. enuExceptionType.BusinessLogicException);
  147. }
  148. }
  149. #endregion
  150. #region --[Métodos publicos]--
  151. public List<Reunion> GetReuniones(Reunion entidad)
  152. {
  153. try
  154. {
  155. return DataAcces.GetReuniones(entidad);
  156. }
  157. catch (CustomizedException ex)
  158. {
  159. throw ex;
  160. }
  161. catch (Exception ex)
  162. {
  163. throw new CustomizedException(string.Format("Fallo en {0} - GetReunions", ClassName), ex,
  164. enuExceptionType.BusinessLogicException);
  165. }
  166. }
  167. #endregion
  168. }
  169. }