public ActionResult Edit(long id, bool isPersonalDashboard) { var model = new TraCrfItemViewModel(); model.MainMenu = _mainMenu; model.CurrentLogin = CurrentUser; var data = _CRFBLL.GetDataById(id); if (!_CRFBLL.IsAllowedEdit(CurrentUser, data)) { return(RedirectToAction("Details", new { id = data.TRA_CRF_ID, isPersonalDashboard = isPersonalDashboard })); } model = InitialModel(model); model.ChangesLogs = GetChangesHistory((int)Enums.MenuList.TraCrf, id); model.Detail = Mapper.Map <TraCrfItemDetails>(data); if (!string.IsNullOrEmpty(model.Detail.LocationCityNew)) { var dataLocationNew = _employeeBLL.GetLocationByCity(model.Detail.LocationCityNew); model.LocationNewList = new SelectList(dataLocationNew, "Location", "Location"); } model.WorkflowLogs = GetWorkflowHistory((int)Enums.MenuList.TraCrf, model.Detail.TraCrfId); var list = _employeeBLL.GetEmployee().Where(x => x.IS_ACTIVE && x.GROUP_LEVEL > 0).Select(x => new { x.EMPLOYEE_ID, x.FORMAL_NAME }).ToList().OrderBy(x => x.FORMAL_NAME); if (CurrentUser.UserRole == Enums.UserRole.Fleet) { list = _employeeBLL.GetEmployee().Where(x => x.IS_ACTIVE).Select(x => new { x.EMPLOYEE_ID, x.FORMAL_NAME }).ToList().OrderBy(x => x.FORMAL_NAME); } model.EmployeeList = new SelectList(list, "EMPLOYEE_ID", "FORMAL_NAME"); var tempData = _CRFBLL.GetTempByCsf(model.Detail.DocumentNumber); model.TemporaryList = Mapper.Map <List <TemporaryData> >(tempData); model.DetailTemporary.StartDate = DateTime.Now; model.DetailTemporary.EndDate = DateTime.Now; var RemarkList = _remarkBLL.GetRemark().Where(x => x.RoleType == CurrentUser.UserRole.ToString() && x.DocumentType == (int)Enums.DocumentType.CRF).ToList(); model.RemarkList = new SelectList(RemarkList, "MstRemarkId", "Remark"); model.IsPersonalDashboard = isPersonalDashboard; return(View(model)); }
public KpiMonitoringItem GetDateworkflow(KpiMonitoringItem item, List <Login> UserLogin) { if (item.FormType.ToUpper() == "CTF") { var ListWorkflow = GetWorkflowHistory((int)Enums.MenuList.TraCtf, item.TraId); var traCtf = _ctfBLL.GetCtfById(item.TraId); var Employee = UserLogin.Where(x => x.EMPLOYEE_ID == (traCtf == null ? "" : traCtf.EmployeeId)).FirstOrDefault(); var Creator = UserLogin.Where(x => x.EMPLOYEE_ID == (traCtf == null ? "" : traCtf.EmployeeIdCreator)).FirstOrDefault(); var Fleet = UserLogin.Where(x => x.EMPLOYEE_ID == (traCtf == null ? "" : traCtf.EmployeeIdFleetApproval)).FirstOrDefault(); var SendToEmp = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Creator == null ? "" : Creator.USER_ID)).FirstOrDefault(); if (SendToEmp != null) { item.SendToEmpDate = SendToEmp.ActionDate; var DaysDiff = _kpiMonitoringBLL.GetDifferentDays(item.EffectiveDate, SendToEmp.ActionDate); if (DaysDiff != null) { item.Kpi1 = DaysDiff; } } if ((traCtf.VehicleUsage == null ? "" : traCtf.VehicleUsage.ToUpper()) == "COP") { var SendBackToHr = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Employee == null ? "" : Employee.USER_ID)).FirstOrDefault(); if (SendBackToHr != null) { item.SendBackToHr = SendBackToHr.ActionDate; } var SendToFleet = ListWorkflow.Where(x => x.Action == Enums.ActionType.Approve.ToString() && x.UserId == (Creator == null ? "" : Creator.USER_ID)).FirstOrDefault(); if (SendToFleet != null) { item.SendToFleetDate = SendToFleet.ActionDate; } } else if ((traCtf.VehicleUsage == null ? "" : traCtf.VehicleUsage.ToUpper()) == "CFM") { var SendToFleet = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Employee == null ? "" : Employee.USER_ID)).FirstOrDefault(); if (SendToFleet != null) { item.SendToFleetDate = SendToFleet.ActionDate; } } } else if (item.FormType.ToUpper() == "CSF") { var ListWorkflow = GetWorkflowHistory((int)Enums.MenuList.TraCsf, item.TraId); var traCsf = _csfBLL.GetCsfById(item.TraId); var Employee = UserLogin.Where(x => x.EMPLOYEE_ID == (traCsf == null ? "" : traCsf.EMPLOYEE_ID)).FirstOrDefault(); var Creator = UserLogin.Where(x => x.EMPLOYEE_ID == (traCsf == null ? "" : traCsf.EMPLOYEE_ID_CREATOR)).FirstOrDefault(); var Fleet = UserLogin.Where(x => x.EMPLOYEE_ID == (traCsf == null ? "" : traCsf.EMPLOYEE_ID_FLEET_APPROVAL)).FirstOrDefault(); var SendToEmp = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Creator == null ? "" : Creator.USER_ID)).FirstOrDefault(); if (SendToEmp != null) { item.SendToEmpDate = SendToEmp.ActionDate; var DaysDiff = _kpiMonitoringBLL.GetDifferentDays(item.EffectiveDate, SendToEmp.ActionDate); if (DaysDiff != null) { item.Kpi1 = DaysDiff; } } var SendBackToHr = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Employee == null ? "" : Employee.USER_ID)).FirstOrDefault(); if (SendBackToHr != null) { item.SendBackToHr = SendBackToHr.ActionDate; } var SendToFleet = ListWorkflow.Where(x => x.Action == Enums.ActionType.Approve.ToString() && x.UserId == (Creator == null ? "" : Creator.USER_ID)).FirstOrDefault(); if (SendToFleet != null) { item.SendToFleetDate = SendToFleet.ActionDate; } var SendVehicleDate = traCsf == null ? null : traCsf.VENDOR_CONTRACT_START_DATE; if (SendVehicleDate != null) { item.SendToEmpBenefit = SendVehicleDate; } } else if (item.FormType.ToUpper() == "CRF") { var ListWorkflow = GetWorkflowHistory((int)Enums.MenuList.TraCtf, item.TraId); var TraCrf = _crfBLL.GetDataById(item.TraId); var Employee = UserLogin.Where(x => x.EMPLOYEE_ID == (TraCrf == null ? "" : TraCrf.EMPLOYEE_ID)).FirstOrDefault(); //var Fleet = UserLogin.Where(x => x.EMPLOYEE_ID == (TraCrf == null ? "" : TraCrf.EmployeeIdFleetApproval)).FirstOrDefault(); var SendToEmp = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (TraCrf == null ? "" : TraCrf.CREATED_BY)).FirstOrDefault(); if (SendToEmp != null) { item.SendToEmpDate = SendToEmp.ActionDate; var DaysDiff = _kpiMonitoringBLL.GetDifferentDays(item.EffectiveDate, SendToEmp.ActionDate); if (DaysDiff != null) { item.Kpi1 = DaysDiff; } } var SendBackToHr = ListWorkflow.Where(x => x.Action == Enums.ActionType.Submit.ToString() && x.UserId == (Employee == null ? "" : Employee.USER_ID)).FirstOrDefault(); if (SendBackToHr != null) { item.SendBackToHr = SendBackToHr.ActionDate; } var SendToFleet = ListWorkflow.Where(x => x.Action == Enums.ActionType.Approve.ToString() && x.UserId == (TraCrf == null ? "" : TraCrf.CREATED_BY)).FirstOrDefault(); if (SendToFleet != null) { item.SendToFleetDate = SendToFleet.ActionDate; } } return(item); }