//[Authorize(Policy = "CreateRolePolicy")] public async Task <IActionResult> Create(LeaveRequestCreateViewModel model) { LeaveRequest leaveRequest = new LeaveRequest { EmployeeId = model.LeaveRequest.EmployeeId, LeaveTypeId = model.LeaveRequest.LeaveTypeId, ApprovalDate = model.LeaveRequest.ApprovalDate, ApprovedBy = model.LeaveRequest.ApprovedBy }; var leaveReq = await leaveRequestService.AddLeaveRequest(leaveRequest); return(RedirectToAction("details", new { id = leaveReq.Id })); }
public async Task <IActionResult> PostLeaveRequest([FromBody] LeaveRequest leaveRequest) { try { var request = await leaveRequestService.AddLeaveRequest(leaveRequest); if (request.Id > 0) { return(Ok(request)); } return(NotFound()); } catch (Exception) { return(BadRequest()); } }
public ActionResult SendLeaveRequest(RequestVacationViewModel vacationRequestViewModel) { if (ModelState.IsValid) { vacationRequestViewModel.VacationTypeID = Convert.ToInt32(vacationRequestViewModel.VacationStringID); vacationRequestViewModel.CreatedOn = DateTime.Today; var employee = (AdminProfileViewModel)Session["EmployeeObj"]; vacationRequestViewModel.CreatedBy = employee.EmployeeID; vacationRequestViewModel.LeaveStatus = "Pending"; //by default leaveRequestService.AddLeaveRequest(vacationRequestViewModel); return(RedirectToAction("SendLeaveRequest")); } else { ModelState.AddModelError("Request", "Invalid Request please try again"); return(RedirectToAction("SendLeaveRequest")); } }