PageRenderTime 33ms CodeModel.GetById 12ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://blpm.googlecode.com/
C# | 185 lines | 137 code | 14 blank | 34 comment | 12 complexity | a9b979bf39dfc8d9bad3b2acf77b7b71 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 BLDirector : BusinessLogicBase<Director, DADirector>
 16    {
 17        #region --[Constante]--
 18        private const string ClassName = "BLDirector";
 19        #endregion
 20
 21        #region --[Constructores]--
 22        /// <summary>
 23        /// Constructor con DTO como parámetro.
 24        /// </summary>
 25        public BLDirector(DTBase objDirector)
 26        {
 27            Data = (Director)objDirector;
 28        }
 29        /// <summary>
 30        /// Constructor vacio
 31        /// </summary>
 32        public BLDirector()
 33        {
 34            Data = new Director();
 35        }
 36        #endregion
 37
 38        #region --[Propiedades Override]--
 39        protected override sealed DADirector DataAcces
 40        {
 41            get { return dataAcces; }
 42            set { dataAcces = value; }
 43        }
 44
 45        public override sealed Director 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 idDirector = 0;
 91
 92                if (Data.idDirector == 0)
 93                    DataAcces.Create(Data, out idDirector);
 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 DADirector(objDATransaction);
124                if (Data.idDirector == 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 DADirector(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        //public List<Director> GetDirectors(Director entidad)
168        //{
169        //    try
170        //    {
171        //        return DataAcces.GetDirectors(entidad);
172        //    }
173        //    catch (CustomizedException ex)
174        //    {
175        //        throw ex;
176        //    }
177        //    catch (Exception ex)
178        //    {
179        //        throw new CustomizedException(string.Format("Fallo en {0} - GetDirectors", ClassName), ex,
180        //                                      enuExceptionType.BusinessLogicException);
181        //    }
182        //}
183        #endregion
184    }
185}