PageRenderTime 41ms CodeModel.GetById 11ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

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