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

http://blpm.googlecode.com/ · C# · 185 lines · 137 code · 14 blank · 34 comment · 12 complexity · 38bfed1d2e973368139fc561e57a3551 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 BLEscala : BusinessLogicBase<Escala, DAEscala>
  15. {
  16. #region --[Constante]--
  17. private const string ClassName = "BLEscala";
  18. #endregion
  19. #region --[Constructores]--
  20. /// <summary>
  21. /// Constructor con DTO como parámetro.
  22. /// </summary>
  23. public BLEscala(DTBase objEscala)
  24. {
  25. Data = (Escala)objEscala;
  26. }
  27. /// <summary>
  28. /// Constructor vacio
  29. /// </summary>
  30. public BLEscala()
  31. {
  32. Data = new Escala();
  33. }
  34. #endregion
  35. #region --[Propiedades Override]--
  36. protected override sealed DAEscala DataAcces
  37. {
  38. get { return dataAcces; }
  39. set { dataAcces = value; }
  40. }
  41. public override sealed Escala 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 idEscala = 0;
  83. if (Data.idEscala == 0)
  84. DataAcces.Create(Data, out idEscala);
  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 DAEscala(objDATransaction);
  113. if (Data.idEscala == 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 DAEscala(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. //public List<Escala> GetEscalas(Escala entidad)
  154. //{
  155. // try
  156. // {
  157. // return DataAcces.GetEscalas(entidad);
  158. // }
  159. // catch (CustomizedException ex)
  160. // {
  161. // throw ex;
  162. // }
  163. // catch (Exception ex)
  164. // {
  165. // throw new CustomizedException(string.Format("Fallo en {0} - GetEscalas", ClassName), ex,
  166. // enuExceptionType.BusinessLogicException);
  167. // }
  168. //}
  169. #endregion
  170. }
  171. }