PageRenderTime 22ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

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

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