public ActionResult RemoveParticipants(string cycleDateRangeStart, string cycleDateRangeEnd, int cycleId, FormCollection form) { Dictionary<string, string> dict = FormCollectionToDict(form); Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); List<Model.DTO.Appraisal.Appraisal> lst_employees = null; if (System.Web.HttpContext.Current.Session["TempRemoveApprIds"] != null) { List<int> tempRemoveApprIds = (List<int>)System.Web.HttpContext.Current.Session["TempRemoveApprIds"]; lst_employees = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId).Where(sec => !tempRemoveApprIds.Contains(sec.Id)).ToList(); } else lst_employees = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId); if (System.Web.HttpContext.Current.Session["CycleExistParticipantsList"] != null) { lst_employees.AddRange((List<Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]); } if (string.IsNullOrEmpty(dict["EmployeeName"].Trim()) && string.IsNullOrEmpty(dict["DomainID"].Trim()) && string.IsNullOrEmpty(dict["DepartmentName"].Trim())) { obj_cycle_management_page.Participants = lst_employees; } else { obj_cycle_management_page.Participants = Business.AppraisalManager.GetApprisalsToRemoveFromCycle(dict["EmployeeName"].Trim(), dict["DomainID"].Trim(), dict["DepartmentName"].Trim(), lst_employees); } if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd)) { ViewData["Stage1EndDate"] = ""; ViewData["Stage3EndDate"] = ""; dict.Add("Stage1EndDate", ""); dict.Add("Stage3EndDate", ""); } else { dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart)); dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd)); ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart); ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd); } ViewData.Model = obj_cycle_management_page; TempData["QueryData"] = dict; return View(); }
public ActionResult AddParticipants(string cycleDateRangeStart, string cycleDateRangeEnd,int cycleId) { if (Business.SecurityManager.HasHRRole(CurrentUser)) { Dictionary<string, string> dict = new Dictionary<string, string>(); Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd)) { ViewData["Stage1EndDate"] = ""; ViewData["Stage3EndDate"] = ""; dict.Add("Stage1EndDate", ""); dict.Add("Stage3EndDate", ""); } else { dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart)); dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd)); ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart); ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd); } ViewData.Model = obj_cycle_management_page; return View(); } else { TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS; return Redirect(Url.Content("~/Home/Index")); } }
public ActionResult RemoveParticipants(string cycleDateRangeStart, string cycleDateRangeEnd, int cycleId) { if (Business.SecurityManager.HasHRRole(CurrentUser)) { Dictionary<string, string> dict = new Dictionary<string, string>(); Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); if (System.Web.HttpContext.Current.Session["TempRemoveApprIds"] != null) { List<int> tempRemoveApprIds = (List<int>)System.Web.HttpContext.Current.Session["TempRemoveApprIds"]; obj_cycle_management_page.Participants = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId).Where(sec => !tempRemoveApprIds.Contains(sec.Id)).ToList(); } else obj_cycle_management_page.Participants = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId); if (System.Web.HttpContext.Current.Session["CycleExistParticipantsList"] != null) { obj_cycle_management_page.Participants.AddRange((List<Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]); } if (Lib.Utility.Common.IsNullOrEmptyList(obj_cycle_management_page.Participants)) { ViewData["AlertMessage"] = "There are no employees to remove."; return Redirect(Url.Content("~/HRManage/ManageCycle/" + cycleDateRangeStart + "/" + cycleDateRangeEnd + "/" + cycleId)); } if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd)) { ViewData["Stage1EndDate"] = ""; ViewData["Stage3EndDate"] = ""; dict.Add("Stage1EndDate", ""); dict.Add("Stage3EndDate", ""); } else { dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart)); dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd)); ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart); ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd); } ModelState.Clear(); ViewData.Model = obj_cycle_management_page; return View(); } else { TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS; return Redirect(Url.Content("~/Home/Index")); } }
public ActionResult ManageCycle(FormCollection form) { string message = string.Empty; Dictionary<string, string> dict = FormCollectionToDict(form); bool boo_update_cycle = Convert.ToInt32(dict["updatecycle"]) == 1 ? true : false; Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); obj_cycle_management_page.Cycles = eHR.PMS.Model.PMSModel.GetCycleByStatus(null); int cycleid = Int32.Parse(form["cycleid"]); if (!boo_update_cycle) { if (cycleid > 0) { obj_cycle_management_page.CurrentCycle = eHR.PMS.Model.PMSModel.GetCycleById(cycleid); obj_cycle_management_page.CurrentCycle.CycleStages = eHR.PMS.Model.PMSModel.GetStagesByCycleId(cycleid); obj_cycle_management_page.Participants = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleid); } } else { PMS.Model.DTO.Cycle.Cycle obj_cycle = eHR.PMS.Model.PMSModel.GetCycleById(cycleid); Dictionary<string, DateTime> dict_cycle_stage_dates = new Dictionary<string, DateTime>(); dict_cycle_stage_dates.Add("PreCStart", DateTime.Now.Date); dict_cycle_stage_dates.Add("PreCEnd", DateTime.ParseExact(dict["Stage1StartDate"], "dd/MM/yyyy", null).AddDays(-1)); dict_cycle_stage_dates.Add("Stage1StartDate", DateTime.ParseExact(dict["Stage1StartDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage1EndDate", DateTime.ParseExact(dict["Stage1EndDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage2StartDate", DateTime.ParseExact(dict["Stage2StartDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage2EndDate", DateTime.ParseExact(dict["Stage2EndDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage3StartDate", DateTime.ParseExact(dict["Stage3StartDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage3EndDate", DateTime.ParseExact(dict["Stage3EndDate"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage1SubmissionDeadline", DateTime.ParseExact(dict["Stage1SubmissionDeadline"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage1Level1ApprovalDeadline", DateTime.ParseExact(dict["Stage1Level1ApprovalDeadline"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage1Level2ApprovalDeadline", DateTime.ParseExact(dict["Stage1Level2ApprovalDeadline"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage2SubmissionDeadline", DateTime.ParseExact(dict["Stage2SubmissionDeadline"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage2Level1ApprovalDeadline", DateTime.ParseExact(dict["Stage2Level1ApprovalDeadline"], "dd/MM/yyyy", null)); dict_cycle_stage_dates.Add("Stage2Level2ApprovalDeadline", DateTime.ParseExact(dict["Stage2Level2ApprovalDeadline"], "dd/MM/yyyy", null)); List<int> deleteApprIdList = new List<int>(); if (System.Web.HttpContext.Current.Session["TempRemoveApprIds"] != null) { deleteApprIdList = (List<int>)System.Web.HttpContext.Current.Session["TempRemoveApprIds"]; if (eHR.PMS.Model.PMSModel.DeleteApprisalInCyle(deleteApprIdList, out message)) { ClearAllCreatedSessionObjects(); return Redirect(Url.Content("~/")); } else { TempData["ErrorMessage"] = "Unable to save cycle information. Please try again or contact IT Department."; return View(); } } List<PMS.Model.DTO.Appraisal.Appraisal> ParticipantsListSessionPart = (List<PMS.Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]; if (ParticipantsListSessionPart != null) { obj_cycle.CycleStages = CreateDefaultStagesForNewCycle(dict_cycle_stage_dates); List<Model.DTO.Core.Employee> emplist = ApprListToEmplList(ParticipantsListSessionPart); obj_cycle.Appriasals = Business.AppraisalManager.CreateAppraisalsForUpdateCycle(emplist, obj_cycle.CycleStages, CurrentUser); if (Business.AppraisalManager.UpdateCycle(obj_cycle, cycleid, Model.Mappers.CoreMapper.MapUserDTOToEmployeeDTO(CurrentUser), out message)) { ClearAllCreatedSessionObjects(); return Redirect(Url.Content("~/")); } else { TempData["ErrorMessage"] = "Unable to save cycle information. Please try again or contact IT Department."; return View(); } } else { // only for updating of cycle dates foreach (PMS.Model.DTO.Cycle.Stage obj_cycle_stage in obj_cycle.CycleStages) { if (obj_cycle_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_GOAL_SETTING) { obj_cycle_stage.StartDate = dict_cycle_stage_dates["Stage1StartDate"]; obj_cycle_stage.EndDate = dict_cycle_stage_dates["Stage1EndDate"]; obj_cycle_stage.SubmissionDeadline = dict_cycle_stage_dates["Stage1SubmissionDeadline"]; obj_cycle_stage.Level1ApprovalDeadline = dict_cycle_stage_dates["Stage1Level1ApprovalDeadline"]; obj_cycle_stage.Level2ApprovalDeadline = dict_cycle_stage_dates["Stage1Level2ApprovalDeadline"]; } if (obj_cycle_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_PROGRESS_REVIEW) { obj_cycle_stage.StartDate = dict_cycle_stage_dates["Stage2StartDate"]; obj_cycle_stage.EndDate = dict_cycle_stage_dates["Stage2EndDate"]; obj_cycle_stage.SubmissionDeadline = dict_cycle_stage_dates["Stage2SubmissionDeadline"]; obj_cycle_stage.Level1ApprovalDeadline = dict_cycle_stage_dates["Stage2Level1ApprovalDeadline"]; obj_cycle_stage.Level2ApprovalDeadline = dict_cycle_stage_dates["Stage2Level2ApprovalDeadline"]; } if (obj_cycle_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_FINAL_YEAR) { obj_cycle_stage.StartDate = dict_cycle_stage_dates["Stage3StartDate"]; obj_cycle_stage.EndDate = dict_cycle_stage_dates["Stage3EndDate"]; } } if (!Lib.Utility.Common.IsNullOrEmptyList(obj_cycle.Appriasals)) { foreach (Model.DTO.Appraisal.Appraisal obj_appraisal in obj_cycle.Appriasals) { foreach (Model.DTO.Appraisal.Stage obj_appraisal_stage in obj_appraisal.AppraisalStages) { if (obj_appraisal_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_GOAL_SETTING) { obj_appraisal_stage.StartDate = dict_cycle_stage_dates["Stage1StartDate"]; obj_appraisal_stage.EndDate = dict_cycle_stage_dates["Stage1EndDate"]; obj_appraisal_stage.SubmissionDeadline = dict_cycle_stage_dates["Stage1SubmissionDeadline"]; obj_appraisal_stage.Level1ApprovalDeadline = dict_cycle_stage_dates["Stage1Level1ApprovalDeadline"]; obj_appraisal_stage.Level2ApprovalDeadline = dict_cycle_stage_dates["Stage1Level2ApprovalDeadline"]; } if (obj_appraisal_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_PROGRESS_REVIEW) { obj_appraisal_stage.StartDate = dict_cycle_stage_dates["Stage2StartDate"]; obj_appraisal_stage.EndDate = dict_cycle_stage_dates["Stage2EndDate"]; obj_appraisal_stage.SubmissionDeadline = dict_cycle_stage_dates["Stage2SubmissionDeadline"]; obj_appraisal_stage.Level1ApprovalDeadline = dict_cycle_stage_dates["Stage2Level1ApprovalDeadline"]; obj_appraisal_stage.Level2ApprovalDeadline = dict_cycle_stage_dates["Stage2Level2ApprovalDeadline"]; } if (obj_appraisal_stage.StageId == PMS.Model.PMSConstants.STAGE_ID_FINAL_YEAR) { obj_appraisal_stage.StartDate = dict_cycle_stage_dates["Stage3StartDate"]; obj_appraisal_stage.EndDate = dict_cycle_stage_dates["Stage3EndDate"]; } } } } //UpdateCycleStage if (Business.AppraisalManager.UpdateCycleStage(obj_cycle.CycleStages, obj_cycle.Appriasals, out message)) { ClearAllCreatedSessionObjects(); return Redirect(Url.Content("~/")); } else { TempData["ErrorMessage"] = "Unable to save cycle information. Please try again or contact IT Department."; return View(); } } /*else { TempData["ErrorMessage"] = "Unable to save cycle information. Please try again or contact IT Department."; return View(); }*/ } TempData["QueryData"] = dict; ViewData["NowDate"] = DateTime.Now.ToString("yyyy-MM-dd"); ViewData.Model = obj_cycle_management_page; return View(); }
public ActionResult ManageCycle(string cycleDateRangeStart, string cycleDateRangeEnd,int? cycleId) { if (Business.SecurityManager.HasHRRole(CurrentUser)) { Dictionary<string, string> dict = new Dictionary<string, string>(); Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); obj_cycle_management_page.Cycles = eHR.PMS.Model.PMSModel.GetCycleByStatus(null); if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd)) { //obj_cycle_management_page.Cycle = new PMS.Model.DTO.Cycle.Cycle(); ; } else { cycleDateRangeStart = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart); cycleDateRangeEnd = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd); //string key = cycleDateRangeStart + " " + cycleDateRangeEnd; if (cycleId.HasValue) { obj_cycle_management_page.CurrentCycle = eHR.PMS.Model.PMSModel.GetCycleById(cycleId.Value); obj_cycle_management_page.CurrentCycle.CycleStages = eHR.PMS.Model.PMSModel.GetStagesByCycleId(cycleId.Value); List<Model.DTO.Appraisal.Appraisal> templist = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId.Value); if (System.Web.HttpContext.Current.Session["TempRemoveApprIds"] != null) { List<int> tempRemoveApprIds = (List<int>)System.Web.HttpContext.Current.Session["TempRemoveApprIds"]; templist = eHR.PMS.Model.PMSModel.GetEmployeesInAppraisalsByCycleId(cycleId.Value).Where(sec => !tempRemoveApprIds.Contains(sec.Id)).ToList(); } if (System.Web.HttpContext.Current.Session["CycleExistParticipantsList"] != null) templist.AddRange((List<Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]); obj_cycle_management_page.Participants = templist; } else { obj_cycle_management_page.Participants = (List<Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]; } /*dict.Add("cyclename", (string)System.Web.HttpContext.Current.Session["CycleName"]); dict.Add("Stage1StartDate", (string)System.Web.HttpContext.Current.Session["Stage1StartDate"]); dict.Add("Stage1EndDate", (string)System.Web.HttpContext.Current.Session["Stage1EndDate"]); dict.Add("Stage2StartDate", (string)System.Web.HttpContext.Current.Session["Stage2StartDate"]); dict.Add("Stage2EndDate", (string)System.Web.HttpContext.Current.Session["Stage2EndDate"]); dict.Add("Stage3StartDate", (string)System.Web.HttpContext.Current.Session["Stage3StartDate"]); dict.Add("Stage3EndDate", (string)System.Web.HttpContext.Current.Session["Stage3EndDate"]); dict.Add("strStage1EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage1EndDate"])); dict.Add("strStage3EndDate", Lib.Utility.Common.ChangeDateFormatVS(dict["Stage3EndDate"])); TempData["QueryData"] = dict;*/ } ModelState.Clear(); ViewData.Model = obj_cycle_management_page; ViewData["NowDate"] = DateTime.Now.ToString("yyyy-MM-dd"); return View(); } else { TempData["AlertMessage"] = Resources.Resource.MSG_FUNCTIONS_NO_ACCESS; return Redirect(Url.Content("~/Home/Index")); } }
public ActionResult AddParticipants(string cycleDateRangeStart, string cycleDateRangeEnd, int cycleId,FormCollection form) { Dictionary<string, string> dict = FormCollectionToDict(form); Models.DTO.CycleManagementPage obj_cycle_management_page = new Models.DTO.CycleManagementPage(); obj_cycle_management_page.Participants = new List<Model.DTO.Appraisal.Appraisal>(); List<Model.DTO.Appraisal.Appraisal> lst_current_participants = new List<Model.DTO.Appraisal.Appraisal>(); if (System.Web.HttpContext.Current.Session["CycleExistParticipantsList"] != null) { lst_current_participants=(List<Model.DTO.Appraisal.Appraisal>)System.Web.HttpContext.Current.Session["CycleExistParticipantsList"]; } List<Model.DTO.Core.Employee> tempEmployeeList = ApprListToEmplList(lst_current_participants); tempEmployeeList=Business.AppraisalManager.GetEmployeesToAddToCycle(form.GetValue("EmployeeName").AttemptedValue == null ? null : form.GetValue("EmployeeName").AttemptedValue.Trim(), form.GetValue("DomainID").AttemptedValue == null ? null : form.GetValue("DomainID").AttemptedValue.Trim(), form.GetValue("DepartmentName").AttemptedValue == null ? null : form.GetValue("DepartmentName").AttemptedValue.Trim(), tempEmployeeList); if (!Lib.Utility.Common.IsNullOrEmptyList(tempEmployeeList)) { foreach (Model.DTO.Core.Employee e in tempEmployeeList) { Model.DTO.Appraisal.Appraisal newapp = new Model.DTO.Appraisal.Appraisal(); newapp.Id = -1; newapp.Employee = e; newapp.Department = e.Department; obj_cycle_management_page.Participants.Add(newapp); } if (!Lib.Utility.Common.IsNullOrEmptyList(obj_cycle_management_page.Participants)) { obj_cycle_management_page.Participants = obj_cycle_management_page.Participants.OrderBy(rec => rec.Department != null ? rec.Department.Name : "").OrderBy(rec => rec.Employee.PreferredName).ToList(); System.Web.HttpContext.Current.Session.Add("CycleNewExistParticipants", obj_cycle_management_page.Participants); } } if (string.IsNullOrEmpty(cycleDateRangeStart) || string.IsNullOrEmpty(cycleDateRangeEnd)) { ViewData["Stage1EndDate"] = ""; ViewData["Stage3EndDate"] = ""; dict.Add("Stage1EndDate", ""); dict.Add("Stage3EndDate", ""); } else { dict.Add("Stage1EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart)); dict.Add("Stage3EndDate", Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd)); ViewData["Stage1EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeStart); ViewData["Stage3EndDate"] = Lib.Utility.Common.ChangeDateFormat(cycleDateRangeEnd); } ViewData.Model = obj_cycle_management_page; TempData["QueryData"] = dict; return View(); }