using System; using System.Data; using Ease.Core.Model; using Ease.Core.DataAccess; using Ease.Core; using System.Collections.Generic; using Ease.Core.Utility; using HRM.BO; namespace HRM.DA { class YearEndValueDetailsRatingService : ServiceTemplate { #region Object Mapping private void MapObject(YearEndValueDetailsRating oYearEndValueDetailsRating, DataReader oReader) { SetObjectID(oYearEndValueDetailsRating, oReader.GetInt32("YearEndValueDetailsRatingID", 0)); oYearEndValueDetailsRating.ObjectiveSetID = oReader.GetInt32("ObjectiveSetID", 0); oYearEndValueDetailsRating.ValueDetailID = oReader.GetInt32("ValueDetailID", 0); oYearEndValueDetailsRating.RatingID = oReader.GetInt32("RatingID") == null ? 0 : oReader.GetInt32("RatingID").Value; //oYearEndValueDetailsRating.EmpComments = oReader.GetString("EmpComments"); //oYearEndValueDetailsRating.LMComments = oReader.GetString("LMComments"); // oYearEndValueDetailsRating.EmpCommentsDate = oReader.GetDateTime("EmpCommentsDate").Value; oYearEndValueDetailsRating.LMRatingDate = oReader.GetDateTime("LMRatingDate") == null ? DateTime.MinValue : oReader.GetDateTime("LMRatingDate").Value; this.SetObjectState(oYearEndValueDetailsRating, ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { YearEndValueDetailsRating oYearEndValueDetailsRating = new YearEndValueDetailsRating(); MapObject(oYearEndValueDetailsRating, oReader); return oYearEndValueDetailsRating as T; } #endregion #region IYearEndValueDetailsRatingService Members #region Get All public List Get() { List oDevelopmentPlan = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc)); oDevelopmentPlan = this.CreateObjects(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 oDevelopmentPlan; } public List GetByPMPYear(int nPMPYearID) { List oObjectives = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.GetByPMPYear(tc, nPMPYearID)); oObjectives = this.CreateObjects(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 oObjectives; } public List GetByObjectiveSetID(int ObjectiveSetID) { List oDevelopmentPlan = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc, ObjectiveSetID)); oDevelopmentPlan = this.CreateObjects(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 oDevelopmentPlan; } #endregion #region Get By ID public YearEndValueDetailsRating Get(int id) { YearEndValueDetailsRating oYearEndValueDetailsRating = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader oreader = new DataReader(YearEndValueDetailsRatingDA.Get(tc, id)); oYearEndValueDetailsRating = 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 oYearEndValueDetailsRating; } #endregion #region Insert public int Save(YearEndValueDetailsRating item) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (item.IsNew) { int id = tc.GenerateID("YearEndValueDetailsRating", "YearEndValueDetailsRatingID"); base.SetObjectID(item, (id)); YearEndValueDetailsRatingDA.Save(tc, item); } else { YearEndValueDetailsRatingDA.Update(tc, item); } tc.End(); return item.ID; } catch (Exception e) { #region Handle Exception if (tc != null) tc.HandleError(); ExceptionLog.Write(e); throw new ServiceException(e.Message, e); #endregion } } #endregion #region Delete public void Delete(int id) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); YearEndValueDetailsRatingDA.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 #endregion } }