public async Task <IActionResult> LeaveApply(LeaveApplyModel leaveApplyModel) { string user = User.FindFirst("Index").Value; var Currentuser = await _taskRepository.GetCurrentUser(user); ViewBag.photo = Currentuser.PhotoURL; leaveApplyModel.EmpId = Currentuser.EmpId; int Eid = leaveApplyModel.EmpId; DateTime date = leaveApplyModel.Startdate; bool existOne = _leaveRepository.CheckExist(Eid, date); if (existOne) { return(RedirectToAction(nameof(LeaveApply), new { isExist = true })); } else { TimeSpan differ = (TimeSpan)(leaveApplyModel.EndDate - leaveApplyModel.Startdate); leaveApplyModel.NoOfDays = differ.Days; if (leaveApplyModel.EvidencePDF != null) { String folder = "images/evidencePDF/"; leaveApplyModel.PdfURL = await UploadPDF(folder, leaveApplyModel.EvidencePDF); } int id = await _leaveRepository.AddLeave(leaveApplyModel); if (id > 0) { return(RedirectToAction(nameof(LeaveApply), new { isSucceess = true, leaveId = id })); } } return(View()); }