public static List<PMS.Model.DTO.Core.Employee> GetEmployees(int Page,Dictionary<string,string> dict, out int pageNum) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == true select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); string domainId = dict["DomainID"]; string userName = dict["UserName"]; if (!string.IsNullOrEmpty(domainId) && !string.IsNullOrEmpty(userName)) { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == true && ent_employees.DOMAIN_ID.Contains(domainId) && ((ent_employees.FIRST_NAME + " " + ent_employees.LAST_NAME).Contains(userName)) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); } else { if (!string.IsNullOrEmpty(dict["DomainID"])) { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == true && ent_employees.DOMAIN_ID.Contains(domainId) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); } else { if (!string.IsNullOrEmpty(dict["UserName"])) { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == true && ((ent_employees.FIRST_NAME + " " + ent_employees.LAST_NAME).Contains(userName)) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); } } } int c = entities.Count(); pageNum = c % pageSize == 0 ? c / pageSize : c / pageSize + 1; if (!eHR.PMS.Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = eHR.PMS.Model.Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.OrderBy(s => s.DOMAIN_ID).Skip((Page - 1) * pageSize).Take(pageSize).ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static List<PMS.Model.DTO.Core.Employee> GetEmployees(int Page,out int pageNum) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == true select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); int c=entities.Count(); pageNum = c % pageSize == 0 ? c / pageSize : c / pageSize + 1; if (!eHR.PMS.Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = eHR.PMS.Model.Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.OrderBy(s=>s.DOMAIN_ID).Skip((Page - 1) * pageSize).Take(pageSize).ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static PMS.Model.DTO.Core.Security.User GetUserByDomainId(string domainId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); PMS.Model.DTO.Core.Security.User obj_user = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; entities = ((from ent_employees in dc_pms.EMPLOYEEs.OrderByDescending(a => a.ID) join ent_user_roles in dc_pms.USER_ROLE on ent_employees.ID equals ent_user_roles.USER_ID into j_emp_role where ent_employees.DOMAIN_ID.Equals(domainId) from ent_emp_role in j_emp_role.DefaultIfEmpty() select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("USER_ROLE") .Include("USER_ROLE.MST_ROLE") .Include("MST_ACR_GRADE"); if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { if (entities.Count() > 1) { } obj_user = PMS.Model.Mappers.CoreMapper.MapEmployeeEntityToUserDTO(entities.First(), true); } dc_pms.Dispose(); return obj_user; }
public static bool DeleteApprisalInCyle(List<int> cids, out string message) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); try { foreach (int cid in cids) { foreach (var item in dc_pms.PMS_APPRAISAL_TRAIL.Where(sec => sec.APPRAISAL_ID == cid)) { dc_pms.PMS_APPRAISAL_TRAIL.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_SECTION.Where(sec => sec.APPRAISAL_ID == cid)) { foreach (var childitem in dc_pms.PMS_APPRAISAL_SECTION_COMMENT.Where(sec => sec.SECTION_ID == item.ID)) { dc_pms.PMS_APPRAISAL_SECTION_COMMENT.DeleteObject(childitem); } dc_pms.PMS_APPRAISAL_SECTION.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_APPROVER.Where(sec => sec.APPRAISAL_ID == cid)) { dc_pms.PMS_APPRAISAL_APPROVER.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_STAGE.Where(sec => sec.APPRAISAL_ID == cid)) { dc_pms.PMS_APPRAISAL_STAGE.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_REVIEWER.Where(sec => sec.APPRAISAL_ID == cid)) { dc_pms.PMS_APPRAISAL_REVIEWER.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_PERFORMANCE_COACHING.Where(sec => sec.APPRAISAL_ID == cid)) { foreach (var childitem in dc_pms.PMS_APPRAISAL_PERFORMANCE_COACHING_COMMENT.Where(sec => sec.ITEM_ID == item.ID)) { dc_pms.PMS_APPRAISAL_PERFORMANCE_COACHING_COMMENT.DeleteObject(childitem); } dc_pms.PMS_APPRAISAL_PERFORMANCE_COACHING.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_KPI.Where(sec => sec.APPRAISAL_ID == cid)) { foreach (var childitem in dc_pms.PMS_APPRAISAL_KPI_COMMENT.Where(sec => sec.ITEM_ID == item.ID)) { dc_pms.PMS_APPRAISAL_KPI_COMMENT.DeleteObject(childitem); } dc_pms.PMS_APPRAISAL_KPI.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_CORE_VALUE.Where(sec => sec.APPRAISAL_ID == cid)) { foreach (var childitem in dc_pms.PMS_APPRAISAL_CORE_VALUE_COMMENT.Where(sec => sec.ITEM_ID == item.ID)) { dc_pms.PMS_APPRAISAL_CORE_VALUE_COMMENT.DeleteObject(childitem); } dc_pms.PMS_APPRAISAL_CORE_VALUE.DeleteObject(item); } foreach (var item in dc_pms.PMS_APPRAISAL_CAREER_DEVELOPMENT.Where(sec => sec.APPRAISAL_ID == cid)) { foreach (var childitem in dc_pms.PMS_APPRAISAL_CAREER_DEVELOPMENT_COMMENT.Where(sec => sec.ITEM_ID == item.ID)) { dc_pms.PMS_APPRAISAL_CAREER_DEVELOPMENT_COMMENT.DeleteObject(childitem); } dc_pms.PMS_APPRAISAL_CAREER_DEVELOPMENT.DeleteObject(item); } foreach (var item in dc_pms.TASKs.Where(sec => sec.RECORD_ID == cid && sec.MODULE_ID == eHR.PMS.Model.PMSConstants.MODULE_ID_PMS)) { foreach (var childitem in dc_pms.TASK_OWNER.Where(sec => sec.TASK_ID == item.ID)) { dc_pms.TASK_OWNER.DeleteObject(childitem); } dc_pms.TASKs.DeleteObject(item); } var appr = dc_pms.PMS_APPRAISAL.Where(sec => sec.ID == cid).FirstOrDefault(); dc_pms.PMS_APPRAISAL.DeleteObject(appr); } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static List<DTO.Cycle.Stage> GetStagesByCycleId(int cycleId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<DTO.Cycle.Stage> lst_stages = null; IEnumerable<PMS.Model.Context.PMS_CYCLE_STAGE> entities; entities = from ent_cycle_stage in dc_pms.PMS_CYCLE_STAGE where ent_cycle_stage.CYCLE_ID == cycleId orderby ent_cycle_stage.STAGE_ID select ent_cycle_stage; if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_stages = Mappers.PMSMapper.MapCycleStageEntitiesToDTOs(entities.ToList()); } return lst_stages; }
public static List<PMS.Model.DTO.Master.Stage> GetMasterStageList(bool? active) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Master.Stage> lst_stages = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_MST_STAGE> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (active == null) { entities = ((from ent_stages in dc_pms.PMS_MST_STAGE select ent_stages).OrderBy(so => so.SORT_ORDER) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_MST_STAGE>); } else { entities = ((from ent_stages in dc_pms.PMS_MST_STAGE where ent_stages.ACTIVE == active select ent_stages).OrderBy(so => so.SORT_ORDER) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_MST_STAGE>); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_stages = Mappers.PMSMapper.MapStageEntitiesToDTOs(entities.ToList()); } dc_pms.Dispose(); return lst_stages; }
public static List<PMS.Model.DTO.Core.Employee> GetIneligibleCycleParticipants(DateTime dateRangeStart, DateTime dateRangeEnd) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_participants = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == false && ent_employees.EMPLOYMENT_TYPE_ID != PMSConstants.EMPLOYMENT_TYPE_ID_PERMANENT && ent_employees.DATE_OF_HIRE >= dateRangeEnd && (ent_employees.DATE_OF_DEPARTURE <= dateRangeStart) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("PMS_LEVEL_1_APPROVER") .Include("PMS_LEVEL_2_APPROVER"); if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_participants = Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_participants; }
public static List<PMS.Model.DTO.Core.Employee> GetEmployeesForCycle(bool? active) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; if (active == null) { entities = ((from ent_employees in dc_pms.EMPLOYEEs select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("PMS_LEVEL_1_APPROVER") .Include("PMS_LEVEL_2_APPROVER") .Include("DEPARMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); } else { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == Convert.ToBoolean(active) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("PMS_LEVEL_1_APPROVER") .Include("PMS_LEVEL_2_APPROVER") .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static bool UpdateSMTMember(PMS.Model.DTO.Appraisal.Appraisal appraisal, PMS.Model.DTO.Appraisal.Reviewer smtMember, out string message, out Model.DTO.Appraisal.Reviewer oldReviewer) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); oldReviewer = null; try { Model.Context.PMS_APPRAISAL_REVIEWER ent_reviewer = (from ent_reviewers in dc_pms.PMS_APPRAISAL_REVIEWER where ent_reviewers.APPRAISAL_ID == appraisal.Id && ent_reviewers.IS_SMT == true select ent_reviewers).SingleOrDefault(); if (ent_reviewer != null) { ent_reviewer.REVIEWER_ID = smtMember.EmployeeId; oldReviewer = Model.Mappers.PMSMapper.MapReviewerEntityToDTO(ent_reviewer); } else { Model.Context.PMS_APPRAISAL_REVIEWER ent_smt_reviewer = Model.Mappers.PMSMapper.MapReviewerDTOTOEntity(smtMember); dc_pms.PMS_APPRAISAL_REVIEWER.AddObject(ent_smt_reviewer); } dc_pms.SaveChanges(); } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateReviewersForAppraisal(int appraisalId, List<DTO.Appraisal.Reviewer> reviewers, out string message, out List<DTO.Appraisal.Reviewer> oldReviewers) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); oldReviewers = null; try { // remove all reviewers for appraisal IEnumerable<Model.Context.PMS_APPRAISAL_REVIEWER> lst_ent_reviewers = from ent_reviewers in dc_pms.PMS_APPRAISAL_REVIEWER where ent_reviewers.APPRAISAL_ID == appraisalId && ent_reviewers.IS_SMT == false select ent_reviewers; if (!Lib.Utility.Common.IsNullOrEmptyList(lst_ent_reviewers)) { oldReviewers = new List<DTO.Appraisal.Reviewer>(); foreach (Model.Context.PMS_APPRAISAL_REVIEWER ent_reviewer in lst_ent_reviewers) { oldReviewers.Add(Model.Mappers.PMSMapper.MapReviewerEntityToDTO(ent_reviewer)); dc_pms.PMS_APPRAISAL_REVIEWER.DeleteObject(ent_reviewer); } } // add new reviewers if (!Lib.Utility.Common.IsNullOrEmptyList(reviewers)) { foreach (DTO.Appraisal.Reviewer obj_reviewer in reviewers) { dc_pms.PMS_APPRAISAL_REVIEWER.AddObject(Mappers.PMSMapper.MapReviewerDTOTOEntity(obj_reviewer)); } } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateCycleStages(List<PMS.Model.DTO.Cycle.Stage> cycleStages, List<PMS.Model.DTO.Appraisal.Appraisal> appraisals, out string message) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); try { foreach (PMS.Model.DTO.Cycle.Stage obj_cycle_stage in cycleStages) { PMS.Model.Context.PMS_CYCLE_STAGE ent_cycle_stage = dc_pms.PMS_CYCLE_STAGE.Where(rec => rec.ID == obj_cycle_stage.Id).Single(); ent_cycle_stage.START_DATE = obj_cycle_stage.StartDate; ent_cycle_stage.END_DATE = obj_cycle_stage.EndDate; ent_cycle_stage.PRE_START_EMAIL_SENT = obj_cycle_stage.PreStartEmailSent; ent_cycle_stage.SUBMISSION_DEADLINE = obj_cycle_stage.SubmissionDeadline; ent_cycle_stage.LEVEL_1_APPROVAL_DEADLINE = obj_cycle_stage.Level1ApprovalDeadline; ent_cycle_stage.LEVEL_2_APPROVAL_DEADLINE = obj_cycle_stage.Level2ApprovalDeadline; } if (!Lib.Utility.Common.IsNullOrEmptyList(appraisals)) { foreach (PMS.Model.DTO.Appraisal.Appraisal obj_appraisal in appraisals) { foreach (PMS.Model.DTO.Appraisal.Stage obj_appraisal_stage in obj_appraisal.AppraisalStages) { PMS.Model.Context.PMS_APPRAISAL_STAGE ent_appraisal_stage = dc_pms.PMS_APPRAISAL_STAGE.Where(rec => rec.ID == obj_appraisal_stage.Id).Single(); ent_appraisal_stage.START_DATE = obj_appraisal_stage.StartDate; ent_appraisal_stage.END_DATE = obj_appraisal_stage.EndDate; ent_appraisal_stage.SUBMISSION_DEADLINE = obj_appraisal_stage.SubmissionDeadline; ent_appraisal_stage.LEVEL_1_APPROVAL_DEADLINE = obj_appraisal_stage.Level1ApprovalDeadline; ent_appraisal_stage.LEVEL_2_APPROVAL_DEADLINE = obj_appraisal_stage.Level2ApprovalDeadline; } } } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateCycleAndCreateAppraisalTasks(PMS.Model.DTO.Cycle.Cycle cycle, int cycleId, out string message,out List<DTO.Appraisal.Appraisal> NewAddAppraisals) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); NewAddAppraisals = new List<DTO.Appraisal.Appraisal>(); try { List<PMS.Model.Context.PMS_CYCLE_STAGE> stages = dc_pms.PMS_CYCLE_STAGE.Where(sec => sec.CYCLE_ID == cycleId).OrderBy(sec=>sec.STAGE_ID).ToList(); int index = 0; foreach (PMS.Model.Context.PMS_CYCLE_STAGE stage in stages) { stage.START_DATE = cycle.CycleStages[index].StartDate; stage.END_DATE = cycle.CycleStages[index].EndDate; index++; } dc_pms.SaveChanges(); message = Convert.ToString(cycleId); foreach (Model.DTO.Appraisal.Appraisal dto_appraisal in cycle.Appriasals) { Model.Context.PMS_APPRAISAL entity_appraisal = Mappers.PMSMapper.MapAppraisalDTOToEntity(dto_appraisal); entity_appraisal.CYCLE_ID = cycleId; dc_pms.PMS_APPRAISAL.AddObject(entity_appraisal); dc_pms.SaveChanges(); foreach (Model.DTO.Appraisal.Section dto_appraisal_section in dto_appraisal.AppraisalSections) { Model.Context.PMS_APPRAISAL_SECTION entity_appraisal_section = Model.Mappers.PMSMapper.MapAppraisalSectionDTOToEntity(dto_appraisal_section); entity_appraisal_section.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_SECTION.AddObject(entity_appraisal_section); } foreach (Model.DTO.Appraisal.Stage dto_appraisal_stage in dto_appraisal.AppraisalStages) { Model.Context.PMS_APPRAISAL_STAGE entity_appraisal_stage = Model.Mappers.PMSMapper.MapAppraisalStageDTOToEntity(dto_appraisal_stage); entity_appraisal_stage.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_STAGE.AddObject(entity_appraisal_stage); } foreach (Model.DTO.Appraisal.Trail dto_appraisal_trail in dto_appraisal.Trails) { Model.Context.PMS_APPRAISAL_TRAIL entity_appraisal_trail = Model.Mappers.PMSMapper.MapAppraisalTrailDTOToEntity(dto_appraisal_trail); entity_appraisal_trail.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_TRAIL.AddObject(entity_appraisal_trail); } foreach (Model.DTO.Appraisal.Approver dto_appraisal_approver in dto_appraisal.Approvers) { Model.Context.PMS_APPRAISAL_APPROVER entity_appraisal_approver = Model.Mappers.PMSMapper.MapApproverDTOToEntity(dto_appraisal_approver); entity_appraisal_approver.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_APPROVER.AddObject(entity_appraisal_approver); } if (!Lib.Utility.Common.IsNullOrEmptyList(dto_appraisal.Reviewers)) { foreach (Model.DTO.Appraisal.Reviewer dto_appraisal_reviewer in dto_appraisal.Reviewers) { Model.Context.PMS_APPRAISAL_REVIEWER entity_appraisal_reviewer = Model.Mappers.PMSMapper.MapReviewerDTOTOEntity(dto_appraisal_reviewer); entity_appraisal_reviewer.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_REVIEWER.AddObject(entity_appraisal_reviewer); } } NewAddAppraisals.Add(Mappers.PMSMapper.MapAppraisalEntityToDTO(entity_appraisal, true)); /* if (dto_appraisal.Task != null) { Model.Context.TASK entity_task = Mappers.CoreMapper.MapTaskDTOToEntity(dto_appraisal.Task); entity_task.RECORD_ID = entity_appraisal.ID; dc_pms.TASKs.AddObject(entity_task); foreach (Model.DTO.Core.Task.Owner obj_owner in dto_appraisal.Task.Owners) { Model.Context.TASK_OWNER entity_owner = Mappers.CoreMapper.MapTaskOwnerDTOToEntity(obj_owner); entity_owner.TASK_ID = entity_task.ID; dc_pms.TASK_OWNER.AddObject(entity_owner); } } */ } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateCycle(PMS.Model.DTO.Cycle.Cycle cycle, out string message) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); try { foreach (PMS.Model.DTO.Cycle.Stage stage in cycle.CycleStages) { PMS.Model.Context.PMS_CYCLE_STAGE entity_cycle_stage = dc_pms.PMS_CYCLE_STAGE.FirstOrDefault(sec => sec.ID == stage.Id); entity_cycle_stage.START_DATE = stage.StartDate; entity_cycle_stage.END_DATE = stage.EndDate; } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateApproversAndTasks(PMS.Model.DTO.Appraisal.Appraisal appraisal, List<PMS.Model.DTO.Appraisal.Approver> approvers, List<PMS.Model.DTO.Core.Task.Owner> taskOwners, out string message, out List<Model.DTO.Appraisal.Approver> oldApprovers) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); oldApprovers = null; try { if (!Lib.Utility.Common.IsNullOrEmptyList(approvers)) { oldApprovers = new List<DTO.Appraisal.Approver>(); IEnumerable<Model.Context.PMS_APPRAISAL_APPROVER> lst_approver_entities = from ent_approvers in dc_pms.PMS_APPRAISAL_APPROVER where ent_approvers.APPRAISAL_ID == appraisal.Id select ent_approvers; foreach (Model.Context.PMS_APPRAISAL_APPROVER ent_approver in lst_approver_entities) { oldApprovers.Add(Model.Mappers.PMSMapper.MapApproverEntityToDTO(ent_approver)); foreach (PMS.Model.DTO.Appraisal.Approver obj_approver in approvers) { if (ent_approver.ID == obj_approver.Id) { ent_approver.APPROVER_ID = obj_approver.EmployeeId; ent_approver.APPROVAL_LEVEL = obj_approver.ApprovalLevel; } } } if (!Lib.Utility.Common.IsNullOrEmptyList(taskOwners)) { List<Int32> lst_task_owner_ids = new List<Int32>(); foreach (PMS.Model.DTO.Core.Task.Owner obj_owners in taskOwners) { lst_task_owner_ids.Add(obj_owners.Id); } IEnumerable<Model.Context.TASK_OWNER> lst_owner_entities = dc_pms.TASK_OWNER.Where(rec => lst_task_owner_ids.Contains(rec.ID)); if (!Lib.Utility.Common.IsNullOrEmptyList(lst_owner_entities)) { foreach (Model.Context.TASK_OWNER ent_owner in lst_owner_entities) { foreach (PMS.Model.DTO.Core.Task.Owner obj_owners in taskOwners) { if (ent_owner.ID == obj_owners.Id) { ent_owner.EMPLOYEE_ID = obj_owners.EmployeeId; } } } } } dc_pms.SaveChanges(); } boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static bool UpdateAppraisalPerformanceCoachingProgress(PMS.Model.DTO.Appraisal.PerformanceCoaching performanceCoaching, out string message) { bool boo_success = false; message = string.Empty; Model.Context.PMS_APPRAISAL_PERFORMANCE_COACHING entity; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); try { if (performanceCoaching != null) { entity = dc_pms.PMS_APPRAISAL_PERFORMANCE_COACHING.Where(rec => rec.APPRAISAL_ID == performanceCoaching.Appraisal.Id).SingleOrDefault(); entity.PROGRESS_UPDATE = performanceCoaching.Progress; dc_pms.SaveChanges(); boo_success = true; } } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static List<PMS.Model.DTO.Core.Employee> GetEmployees(bool? active) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (active == null) { entities = ((from ent_employees in dc_pms.EMPLOYEEs select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("PMS_LEVEL_1_APPROVER") .Include("PMS_LEVEL_2_APPROVER") .Include("MST_EMPLOYMENT_TYPE") .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT") .Include("MST_ACR_GRADE") .Include("SENIOR_MANAGEMENT_TEAM_MEMBER"); } else { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == active select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>) .Include("PMS_LEVEL_1_APPROVER") .Include("PMS_LEVEL_2_APPROVER") .Include("MST_EMPLOYMENT_TYPE") .Include("DEPARTMENT") .Include("DEPARTMENT.MST_DEPARTMENT") .Include("MST_ACR_GRADE") .Include("SENIOR_MANAGEMENT_TEAM_MEMBER"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static List<PMS.Model.DTO.Core.Employee> GetEmployeesByName(bool? active, string name) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Employee> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (active == null) { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ((ent_employees.FIRST_NAME + " " + ent_employees.LAST_NAME).Contains(name)) || ent_employees.DOMAIN_ID.Contains(name) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>); } else { entities = ((from ent_employees in dc_pms.EMPLOYEEs where ent_employees.ACTIVE == active && ((ent_employees.FIRST_NAME + " " + ent_employees.LAST_NAME).Contains(name)) || ent_employees.DOMAIN_ID.Contains(name) select ent_employees) as System.Data.Objects.ObjectQuery<PMS.Model.Context.EMPLOYEE>); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = Mappers.CoreMapper.MapEmployeeEntitiesToDTOs(entities.Take(5).ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static List<PMS.Model.DTO.Appraisal.Appraisal> GetAppraisalsInCycleToApprove(int approverEmployeeId, int? cycleId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Appraisal.Appraisal> lst_appraisals = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (cycleId == null) { entities = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_approvers in dc_pms.PMS_APPRAISAL_APPROVER on ent_appraisal.ID equals ent_approvers.APPRAISAL_ID where ent_approvers.APPROVER_ID == approverEmployeeId select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>) .Include("PMS_CYCLE") .Include("MST_DEPARTMENT") .Include("EMPLOYEE") .Include("PMS_APPRAISAL_STAGE") .Include("PMS_APPRAISAL_STAGE.PMS_MST_STAGE") .Include("PMS_MST_STATUS") .Include("PMS_APPRAISAL_APPROVER") .Include("PMS_APPRAISAL_APPROVER.EMPLOYEE"); } else { entities = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_cycles in dc_pms.PMS_CYCLE on ent_appraisal.CYCLE_ID equals ent_cycles.ID join ent_approvers in dc_pms.PMS_APPRAISAL_APPROVER on ent_appraisal.ID equals ent_approvers.APPRAISAL_ID where ent_cycles.ID == cycleId && ent_approvers.APPROVER_ID == approverEmployeeId select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>) .Include("PMS_CYCLE") .Include("MST_DEPARTMENT") .Include("EMPLOYEE") .Include("PMS_APPRAISAL_STAGE") .Include("PMS_APPRAISAL_STAGE.PMS_MST_STAGE") .Include("PMS_MST_STATUS") .Include("PMS_APPRAISAL_APPROVER") .Include("PMS_APPRAISAL_APPROVER.EMPLOYEE"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_appraisals = PMS.Model.Mappers.PMSMapper.MapAppraisalEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_appraisals; }
public static List<PMS.Model.DTO.Appraisal.Appraisal> GetEmployeesInAppraisalsByCycleId(int cycleId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Appraisal.Appraisal> lst_employees = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; entities = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_employee in dc_pms.EMPLOYEEs on ent_appraisal.EMPLOYEE_ID equals ent_employee.ID where ent_appraisal.CYCLE_ID == cycleId select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>) .Include("EMPLOYEE") .Include("MST_DEPARTMENT") .Include("PMS_MST_STAGE") .Include("PMS_MST_STATUS") .Include("PMS_APPRAISAL_APPROVER") .Include("PMS_APPRAISAL_APPROVER.EMPLOYEE"); if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_employees = Mappers.PMSMapper.MapAppraisalEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_employees; }
public static void GetAppraisalsInCycleToReview(int reviewerEmployeeId, int? cycleId, out List<PMS.Model.DTO.Appraisal.Appraisal> MyAppraisalsToReview, out List<PMS.Model.DTO.Appraisal.Appraisal> MyAppraisalsToReviewSMT) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); //List<PMS.Model.DTO.Appraisal.Appraisal> lst_appraisals = null; MyAppraisalsToReview = new List<DTO.Appraisal.Appraisal>(); MyAppraisalsToReviewSMT = new List<DTO.Appraisal.Appraisal>(); System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL> entities; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL> entitiessmt; dc_pms.ContextOptions.LazyLoadingEnabled = true; if (cycleId == null) { entities = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_cycle in dc_pms.PMS_CYCLE on ent_appraisal.CYCLE_ID equals ent_cycle.ID join ent_reviewer in dc_pms.PMS_APPRAISAL_REVIEWER on ent_appraisal.ID equals ent_reviewer.APPRAISAL_ID where ent_reviewer.REVIEWER_ID == reviewerEmployeeId && (ent_reviewer.IS_SMT == null || ent_reviewer.IS_SMT == false) select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>); //.Include("EMPLOYEE") //.Include("EMPLOYEE.DEPARTMENT") //.Include("EMPLOYEE.DEPARTMENT.MST_DEPARTMENT"); entitiessmt = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_cycle in dc_pms.PMS_CYCLE on ent_appraisal.CYCLE_ID equals ent_cycle.ID join ent_reviewer in dc_pms.PMS_APPRAISAL_REVIEWER on ent_appraisal.ID equals ent_reviewer.APPRAISAL_ID where ent_reviewer.REVIEWER_ID == reviewerEmployeeId && ent_reviewer.IS_SMT == true select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>); //.Include("EMPLOYEE") //.Include("EMPLOYEE.DEPARTMENT") //.Include("EMPLOYEE.DEPARTMENT.MST_DEPARTMENT"); } else { entities = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_cycle in dc_pms.PMS_CYCLE on ent_appraisal.CYCLE_ID equals ent_cycle.ID join ent_reviewer in dc_pms.PMS_APPRAISAL_REVIEWER on ent_appraisal.ID equals ent_reviewer.APPRAISAL_ID where ent_reviewer.REVIEWER_ID == reviewerEmployeeId && ent_cycle.ID == cycleId && (ent_reviewer.IS_SMT==null || ent_reviewer.IS_SMT==false) select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>); //.Include("EMPLOYEE") //.Include("EMPLOYEE.DEPARTMENT") //.Include("EMPLOYEE.DEPARTMENT.MST_DEPARTMENT"); entitiessmt = ((from ent_appraisal in dc_pms.PMS_APPRAISAL join ent_cycle in dc_pms.PMS_CYCLE on ent_appraisal.CYCLE_ID equals ent_cycle.ID join ent_reviewer in dc_pms.PMS_APPRAISAL_REVIEWER on ent_appraisal.ID equals ent_reviewer.APPRAISAL_ID where ent_reviewer.REVIEWER_ID == reviewerEmployeeId && ent_cycle.ID == cycleId && ent_reviewer.IS_SMT == true select ent_appraisal) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL>); //.Include("EMPLOYEE") //.Include("EMPLOYEE.DEPARTMENT") //.Include("EMPLOYEE.DEPARTMENT.MST_DEPARTMENT"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { MyAppraisalsToReview = PMS.Model.Mappers.PMSMapper.MapAppraisalEntitiesToDTOs(entities.ToList(), true); } if (!Lib.Utility.Common.IsNullOrEmptyList(entitiessmt)) { MyAppraisalsToReviewSMT = PMS.Model.Mappers.PMSMapper.MapAppraisalEntitiesToDTOs(entitiessmt.ToList(), true); } dc_pms.Dispose(); return; //return lst_appraisals; }
public static int GetLatestActiveCycleId() { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); int int_id = 0; try { dc_pms.ContextOptions.LazyLoadingEnabled = false; var cycle = (from ent_cycle in dc_pms.PMS_CYCLE.OrderByDescending(a => a.STARTED_TIMESTAMP) where ent_cycle.STATUS_ID == PMSConstants.STATUS_ID_OPEN select ent_cycle).FirstOrDefault(); if (cycle != null) { int_id = cycle.ID; } } catch (Exception exc) { throw exc; } finally { dc_pms.Dispose(); } return int_id; }
public static List<PMS.Model.DTO.Appraisal.Approver> GetApproversByAppraisalId(int appraisalId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Appraisal.Approver> lst_approvers = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL_APPROVER> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; entities = ((from ent_approvers in dc_pms.PMS_APPRAISAL_APPROVER where ent_approvers.APPRAISAL_ID == appraisalId select ent_approvers) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_APPRAISAL_APPROVER>) .Include("EMPLOYEE"); if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_approvers = PMS.Model.Mappers.PMSMapper.MapApproverEntitiesToDTOs(entities.ToList()); } return lst_approvers; }
public static PMS.Model.DTO.Master.Section GetSectionById(int sectionId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); PMS.Model.DTO.Master.Section obj_section = null; PMS.Model.Context.PMS_MST_SECTION entity; dc_pms.ContextOptions.LazyLoadingEnabled = false; entity = (from ent_sections in dc_pms.PMS_MST_SECTION .Include("PMS_MST_BLOCK") where ent_sections.ID == sectionId select ent_sections).Single(); if (entity != null) { obj_section = Mappers.PMSMapper.MapSectionEntityToDTO(entity, true); } dc_pms.Dispose(); return obj_section; }
public static List<PMS.Model.DTO.GradeCompetency> GetCoreValueCompetencyByGrade(int? gradeId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.GradeCompetency> lst_competencies = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_GRADE_CORE_VALUE_COMPETENCY> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (gradeId == null) { entities = ((from ent_grade_competency in dc_pms.PMS_GRADE_CORE_VALUE_COMPETENCY select ent_grade_competency) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_GRADE_CORE_VALUE_COMPETENCY>) .Include("MST_ACR_GRADE") .Include("PMS_MST_BLOCK") .Include("PMS_MST_CORE_VALUE_COMPETENCY"); } else { entities = ((from ent_grade_competency in dc_pms.PMS_GRADE_CORE_VALUE_COMPETENCY where ent_grade_competency.GRADE_MASTER_ID == gradeId select ent_grade_competency) as System.Data.Objects.ObjectQuery<PMS.Model.Context.PMS_GRADE_CORE_VALUE_COMPETENCY>) .Include("MST_ACR_GRADE") .Include("PMS_MST_BLOCK") .Include("PMS_MST_CORE_VALUE_COMPETENCY"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_competencies = Mappers.PMSMapper.MapGradeCompetencyEntitiesToDTOs(entities.ToList()); } dc_pms.Dispose(); return lst_competencies; }
public static PMS.Model.DTO.Core.Task.Task GetTaskById(int taskId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); PMS.Model.DTO.Core.Task.Task obj_task = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.TASK> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; Model.Context.TASK ent_task = ((from ent_tasks in dc_pms.TASKs where ent_tasks.ID == taskId select ent_tasks) as System.Data.Objects.ObjectQuery<PMS.Model.Context.TASK>) .Include("MST_MODULE") .Include("MST_STATUS") .Include("TASK_OWNER") .Include("TASK_OWNER.EMPLOYEE").SingleOrDefault(); if (ent_task != null) { obj_task = Mappers.CoreMapper.MapTaskEntityToDTO(ent_task, true); } return obj_task; }
public static DTO.Cycle.Cycle GetCycleById(int Id) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); DTO.Cycle.Cycle obj_cycle = null; PMS.Model.Context.PMS_CYCLE entity; entity = (from ent_cycles in dc_pms.PMS_CYCLE where ent_cycles.ID == Id select ent_cycles).SingleOrDefault(); if (entity != null) { obj_cycle = Mappers.PMSMapper.MapCycleEntityToDTO(entity, true); } return obj_cycle; }
public static List<PMS.Model.DTO.Core.Task.Task> GetTasksByOwner(int ownerEmployeeId, int? statusId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<PMS.Model.DTO.Core.Task.Task> lst_tasks = null; System.Data.Objects.ObjectQuery<PMS.Model.Context.TASK> entities; dc_pms.ContextOptions.LazyLoadingEnabled = false; if (statusId != null) { entities = ((from ent_tasks in dc_pms.TASKs join ent_owners in dc_pms.TASK_OWNER on ent_tasks.ID equals ent_owners.TASK_ID where ent_tasks.MODULE_ID == PMSConstants.MODULE_ID_PMS && ent_tasks.STATUS_ID == statusId && ent_owners.EMPLOYEE_ID == ownerEmployeeId select ent_tasks) as System.Data.Objects.ObjectQuery<PMS.Model.Context.TASK>) .Include("MST_MODULE") .Include("MST_STATUS") .Include("TASK_OWNER") .Include("TASK_OWNER.EMPLOYEE"); } else { entities = ((from ent_tasks in dc_pms.TASKs join ent_owners in dc_pms.TASK_OWNER on ent_tasks.ID equals ent_owners.TASK_ID where ent_tasks.MODULE_ID == PMSConstants.MODULE_ID_PMS && ent_owners.EMPLOYEE_ID == ownerEmployeeId select ent_tasks) as System.Data.Objects.ObjectQuery<PMS.Model.Context.TASK>) .Include("MST_MODULE") .Include("MST_STATUS") .Include("TASK_OWNER") .Include("TASK_OWNER.EMPLOYEE"); } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_tasks = PMS.Model.Mappers.CoreMapper.MapTaskEntitiesToDTOs(entities.ToList(), true); } dc_pms.Dispose(); return lst_tasks; }
public static List<DTO.Cycle.Cycle> GetCycleByStatus(int? statusId) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); List<DTO.Cycle.Cycle> lst_cycles = null; IEnumerable<PMS.Model.Context.PMS_CYCLE> entities; if (statusId == null) { entities = from ent_cycles in dc_pms.PMS_CYCLE select ent_cycles; } else { entities = from ent_cycles in dc_pms.PMS_CYCLE where ent_cycles.STATUS_ID == statusId select ent_cycles; } if (!Lib.Utility.Common.IsNullOrEmptyList(entities)) { lst_cycles = Mappers.PMSMapper.MapCycleEntitiesToDTOs(entities.ToList(), true); } return lst_cycles; }
public static bool InsertNewCycleAndCreateAppraisalTasks(PMS.Model.DTO.Cycle.Cycle cycle, out string message) { bool boo_success = false; message = string.Empty; PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); try { PMS.Model.Context.PMS_CYCLE entity_cycle = Mappers.PMSMapper.MapCycleDTOToEntity(cycle, false); dc_pms.PMS_CYCLE.AddObject(entity_cycle); foreach (Model.DTO.Cycle.Stage dto_cycle_stage in cycle.CycleStages) { Model.Context.PMS_CYCLE_STAGE entity_cycle_stage = Mappers.PMSMapper.MapCycleStageDTOToEntity(dto_cycle_stage); entity_cycle_stage.CYCLE_ID = entity_cycle.ID; dc_pms.PMS_CYCLE_STAGE.AddObject(entity_cycle_stage); } dc_pms.SaveChanges(); message = Convert.ToString(entity_cycle.ID); foreach (Model.DTO.Appraisal.Appraisal dto_appraisal in cycle.Appriasals) { Model.Context.PMS_APPRAISAL entity_appraisal = Mappers.PMSMapper.MapAppraisalDTOToEntity(dto_appraisal); entity_appraisal.CYCLE_ID = entity_cycle.ID; dc_pms.PMS_APPRAISAL.AddObject(entity_appraisal); dc_pms.SaveChanges(); foreach (Model.DTO.Appraisal.Section dto_appraisal_section in dto_appraisal.AppraisalSections) { Model.Context.PMS_APPRAISAL_SECTION entity_appraisal_section = Model.Mappers.PMSMapper.MapAppraisalSectionDTOToEntity(dto_appraisal_section); entity_appraisal_section.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_SECTION.AddObject(entity_appraisal_section); } foreach (Model.DTO.Appraisal.Stage dto_appraisal_stage in dto_appraisal.AppraisalStages) { Model.Context.PMS_APPRAISAL_STAGE entity_appraisal_stage = Model.Mappers.PMSMapper.MapAppraisalStageDTOToEntity(dto_appraisal_stage); entity_appraisal_stage.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_STAGE.AddObject(entity_appraisal_stage); } foreach (Model.DTO.Appraisal.Trail dto_appraisal_trail in dto_appraisal.Trails) { Model.Context.PMS_APPRAISAL_TRAIL entity_appraisal_trail = Model.Mappers.PMSMapper.MapAppraisalTrailDTOToEntity(dto_appraisal_trail); entity_appraisal_trail.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_TRAIL.AddObject(entity_appraisal_trail); } foreach (Model.DTO.Appraisal.Approver dto_appraisal_approver in dto_appraisal.Approvers) { Model.Context.PMS_APPRAISAL_APPROVER entity_appraisal_approver = Model.Mappers.PMSMapper.MapApproverDTOToEntity(dto_appraisal_approver); entity_appraisal_approver.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_APPROVER.AddObject(entity_appraisal_approver); } foreach (Model.DTO.Appraisal.Reviewer dto_appraisal_reviewer in dto_appraisal.Reviewers) { Model.Context.PMS_APPRAISAL_REVIEWER entity_appraisal_reviewer = Model.Mappers.PMSMapper.MapReviewerDTOTOEntity(dto_appraisal_reviewer); entity_appraisal_reviewer.APPRAISAL_ID = entity_appraisal.ID; dc_pms.PMS_APPRAISAL_REVIEWER.AddObject(entity_appraisal_reviewer); } /* if (dto_appraisal.Task != null) { Model.Context.TASK entity_task = Mappers.CoreMapper.MapTaskDTOToEntity(dto_appraisal.Task); entity_task.RECORD_ID = entity_appraisal.ID; dc_pms.TASKs.AddObject(entity_task); foreach (Model.DTO.Core.Task.Owner obj_owner in dto_appraisal.Task.Owners) { Model.Context.TASK_OWNER entity_owner = Mappers.CoreMapper.MapTaskOwnerDTOToEntity(obj_owner); entity_owner.TASK_ID = entity_task.ID; dc_pms.TASK_OWNER.AddObject(entity_owner); } } */ } dc_pms.SaveChanges(); boo_success = true; } catch (Exception exc) { message = exc.Message; } finally { dc_pms.Dispose(); } return boo_success; }
public static PMS.Model.DTO.Core.Employee GetEmployeeById(int id) { PMS.Model.Context.PMSEntities dc_pms = new PMS.Model.Context.PMSEntities(); PMS.Model.DTO.Core.Employee employee = new DTO.Core.Employee(); PMS.Model.Context.EMPLOYEE entity; dc_pms.ContextOptions.LazyLoadingEnabled = false; entity=(from ent_employee in dc_pms.EMPLOYEEs where ent_employee.ID==id select ent_employee).Single(); employee = Mappers.CoreMapper.MapEmployeeEntityToDTO(entity); return employee; }