public IActionResult Details(LeaveRequestViewModel model) { var request = _mapper.Map <LeaveRequest>(model); request.RequestingEmployee = _employeeRepository.FindById(Guid.Parse(model.RequestingEmployeeId)); request.ApprovedBy = _employeeRepository.FindById(Guid.Parse(_userManager.GetUserAsync(User).Result.Id)); request.LeaveType = _leaveTypeRepository.FindById(model.LeaveTypeId); if (request.Approved == true) { var allocation = _leaveAllocationRepository.GetLeaveAllocationByEmployeeAndLeaveType(request.RequestingEmployee.Id, request.LeaveType.Id); allocation.NumberOfDays -= (int)(request.EndDate - request.StartDate).TotalDays; _leaveAllocationRepository.Update(allocation); } _leaveRequestRepository.Update(request); return(RedirectToAction("Index")); }