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 { #region CreatedRequisition Service public class CreatedRequisitionService : ServiceTemplate, ICreatedRequisitionService { public CreatedRequisitionService() { } private void MapObject(CreatedRequisition oCreatedRequisition, DataReader oReader) { base.SetObjectID(oCreatedRequisition, (oReader.GetInt32("CreatedRequisitionID").Value)); oCreatedRequisition.EmpRequisitionID = oReader.GetInt32("RecruitementProcessID", 0); oCreatedRequisition.EmpRequisitionID = oReader.GetInt32("EmpRequisitionID", 0); this.SetObjectState(oCreatedRequisition, Ease.Core.ObjectState.Saved); } protected override T CreateObject(DataReader oReader) { CreatedRequisition oCreatedRequisition = new CreatedRequisition(); MapObject(oCreatedRequisition, oReader); return oCreatedRequisition as T; } protected CreatedRequisition CreateObject(DataReader oReader) { CreatedRequisition oCreatedRequisition = new CreatedRequisition(); MapObject(oCreatedRequisition, oReader); return oCreatedRequisition; } #region Service implementation public List Get() { List CreatedRequisitions = null; TransactionContext tc = null; try { tc = TransactionContext.Begin(); DataReader dr = new DataReader(CreatedRequisitionDA.Get(tc)); CreatedRequisitions = 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 CreatedRequisitions; } public int Save(CreatedRequisition oCreatedRequisition) { TransactionContext tc = null; try { tc = TransactionContext.Begin(true); if (oCreatedRequisition.IsNew) { int id = tc.GenerateID("CreatedRequisition", "CreatedRequisitionID"); base.SetObjectID(oCreatedRequisition, (id)); CreatedRequisitionDA.Insert(tc, oCreatedRequisition); } tc.End(); return oCreatedRequisition.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); CreatedRequisitionDA.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 }