using HRM.BO; using Ease.Core.DataAccess; using Ease.Core.Model; using Ease.Core.Utility; using System; using System.Collections.Generic; namespace HRM.DA { public class FestivalBonusProjectionService : ServiceTemplate, IFestivalBonusProjectionService { public FestivalBonusProjectionService() { } private void MapObject(FestivalBonusProjection oFestivalBonusProjection, DataReader oReader) { base.SetObjectID(oFestivalBonusProjection, oReader.GetInt32("FestivalBonusProjectionID").Value); oFestivalBonusProjection.BasicMonth = (EnumMonths)oReader.GetInt16("basicmonth").Value; oFestivalBonusProjection.NoofBasic = oReader.GetDouble("noofbasic").Value; oFestivalBonusProjection.Sequence = oReader.GetInt32("SequenceNO").Value; oFestivalBonusProjection.Status = (EnumStatus)oReader.GetInt32("Status").Value; oFestivalBonusProjection.CreatedBy = oReader.GetInt32("CreatedBy", 0); oFestivalBonusProjection.CreatedDate = oReader.GetDateTime("CreationDate").Value; oFestivalBonusProjection.ModifiedBy = oReader.GetInt32("ModifiedBy", 0); oFestivalBonusProjection.ModifiedDate = oReader.GetDateTime("ModifiedDate"); this.SetObjectState(oFestivalBonusProjection, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); MapObject(oFestivalBonusProjection, oReader); return oFestivalBonusProjection as T; } protected FestivalBonusProjection CreateObject(DataReader oReader) { FestivalBonusProjection oFestivalBonusProjection = new FestivalBonusProjection(); MapObject(oFestivalBonusProjection, oReader); return oFestivalBonusProjection; } #region Service implementation public FestivalBonusProjection Get(int id) { FestivalBonusProjection oFestivalBonusProjection = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(FestivalBonusProjectionDA.Get(tc, id)); if (oreader.Read()) { oFestivalBonusProjection = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oFestivalBonusProjection; } public FestivalBonusProjection Get(EnumMonths dBasicMonth) { FestivalBonusProjection oFestivalBonusProjection = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(FestivalBonusProjectionDA.Get(tc, dBasicMonth)); if (oreader.Read()) { oFestivalBonusProjection = this.CreateObject(oreader); } oreader.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return oFestivalBonusProjection; } public List Get(EnumStatus status) { List FestivalBonusProjections = new List(); TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(FestivalBonusProjectionDA.Get(tc, status)); FestivalBonusProjections = this.CreateObjects(dr); dr.Close(); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } return FestivalBonusProjections; } public int Save(FestivalBonusProjection oFestivalBonusProjection) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oFestivalBonusProjection.IsNew) { int id = tc.GenerateID("FestivalBonusProjection", "FestivalBonusProjectionID"); base.SetObjectID(oFestivalBonusProjection, id); int seqNo = tc.GenerateID("FestivalBonusProjection", "SequenceNo"); oFestivalBonusProjection.Sequence = seqNo; FestivalBonusProjectionDA.Insert(tc, oFestivalBonusProjection); } else { FestivalBonusProjectionDA.Update(tc, oFestivalBonusProjection); } tc.End(); return oFestivalBonusProjection.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); FestivalBonusProjectionDA.Delete(tc, id); tc.End(); } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } #endregion } }