public LeaveApplicationDTOs CreateLeaveApplicationInformation(int empcode, int leaveid, string recommendType) { LeaveApplicationDTOs Result = new LeaveApplicationDTOs(); Result.LeaveEmpCode = empcode; Result.LeaveTypeId = leaveid; Result.LeaveTypeName = _unitOfWork.LeaveTypeRepository.All().Where(x => x.LeaveTypeId == leaveid).Select(x => x.LeaveTypeName).FirstOrDefault(); var leaveTypeData = _unitOfWork.LeaveTypeRepository.All().Where(x => x.LeaveTypeId == leaveid).FirstOrDefault(); // Result.Leavetypes.HalfdayAllow = leaveTypeData.HalfdayAllow; Result.IsHalfDayAllow = leaveTypeData.HalfdayAllow; LeaveBalance LeaveBalance = LeavebalanceIndividual(null, empcode, leaveid); if (LeaveBalance.Leave_Balance <= 0) { throw new Exception("This Leave Is not assigned for you ."); } else if (LeaveBalance.LeaveTypeAssignment != "General") { throw new Exception("Special Leave can not be applied from here.."); } Result.ApproverList = _DynamicSelectList.GetLeaveApproverSelectList(empcode, recommendType).ToList(); Result.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(empcode, recommendType).ToList(); return(Result); }
public ActionResult Create(LeaveApplicationDTOs Record, int EmpCode, int levid) { string recommendType = "General"; Record.LeaveStartDate = !string.IsNullOrEmpty(Record.LeaveStartDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveStartDateNP)) : Record.LeaveStartDate; Record.LeaveEndDate = !string.IsNullOrEmpty(Record.LeaveEndDateNP) ? Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveEndDateNP)) : Record.LeaveEndDate; try { if (Record.IsHalfDay == true) { Record.LeaveEndDate = Record.LeaveStartDate; } if (ModelState.IsValid) { LeaveApplicationDTOs data = _ValidateLeave.ValidateLeave(Record); if (data.ErrorList != null && data.ErrorList.Count > 0) { data.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList(); data.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList; return(View(data)); } else { _LeaveAddAdmin.LeaveApplicationCreate(Record); Session["success"] = "Leave Created Sucessfully "; return(RedirectToAction("LeaveApplistList", new { EmpCode = EmpCode })); } } else { Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList(); Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList; return(View(Record)); } } catch (Exception Ex) { Session["error"] = Ex.Message; Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(EmpCode, recommendType).ToList(); Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(EmpCode, levid, recommendType).ApproverList; return(View(Record)); } }
public ActionResult Update(int id) { int curentemp = Convert.ToInt32(Session["Empcode"]); int roleid = Convert.ToInt32(Session["RoleId"]); LeaveEarnedDTO Record = new LeaveEarnedDTO(); Record = _LeaveEarnedService.GetOneLeaveEarned(id); Record.WorkedStartDateNP = NepEngDate.EngToNep(Record.WorkedStartDate); Record.WorkedEndDateNP = NepEngDate.EngToNep(Record.WorkedEndDate); Record.YearSelectList = _SpecialleavetypeService.GetYearSelectList(); Record.LeaveTypeSelectList = _LeaveEarnedService.GetEarnedLeaveTypeList(); // Record.EmployeeCodeSelectlist = _LeaveEarnedService.GetSelectedBranchEmployeeSelectList(curentemp,Convert.ToInt32(Record.EmpCode)); Record.ApproveEmployeeCodeSelectlist = _DynamicSelectList.GetLeaveApproverSelectList(Record.EmpCode, "Earning"); Record.EmpId = Record.EmpCode; Record.GetRecommederSelectList = _DynamicSelectList.GetLeaveRecommenderSelectList(Record.EmpCode, "Earning"); return(View("../Leave/LeaveEarned/Update", Record)); }
public ActionResult Create(LeaveApplicationDTOs Record, int levid) { string recommendType = "General"; int empcode = Convert.ToInt32(Session["EmpCode"]); Record.ApproverList = _DynamicSelectList.GetLeaveApproverSelectList(empcode, recommendType).ToList(); Record.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(empcode, recommendType).ToList(); try { Record.LeaveStartDate = Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveStartDateNP)); Record.LeaveEndDate = Convert.ToDateTime(NepEngDate.NepToEng(Record.LeaveEndDateNP)); if (Record.IsHalfDay) { Record.LeaveEndDate = Record.LeaveStartDate; } if (ModelState.IsValid) { Record = _ValidateLeave.ValidateLeave(Record); if (Record.ErrorList != null && Record.ErrorList.Count > 0) { return(View(Record)); } else { _LeaveAddAdmin.LeaveApplicationCreate(Record); Session["success"] = "Leave Created Sucessfully "; return(RedirectToAction("Index")); } } else { Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(empcode, Record.LeaveTypeId, recommendType).ApproverList; return(View(Record)); } } catch (Exception Ex) { Session["error"] = Ex.Message; Record.ApproverList = _LeaveAddAdmin.CreateLeaveApplicationInformation(empcode, Record.LeaveTypeId, recommendType).ApproverList; return(View(Record)); } }