// GET: VacationTypesController/Details/5 public async Task <ActionResult> Details(int id) { var isExists = await _repo.isExists(id); if (!isExists) { return(NotFound()); } var vacationType = _repo.FindById(id); var model = _mapper.Map <VacationTypeVM>(vacationType); return(View(model)); }
public async Task <ActionResult> SetLeave(int id) { var vacationtype = await _typerepo.FindById(id); var employees = _userManager.GetUsersInRoleAsync("Employee").Result; foreach (var emp in employees) { var checkAllocation = await _allocationrepo.CheckAllocation(id, emp.Id); if (checkAllocation) { continue; } var allocation = new VacationAllocationVM { DateCreated = DateTime.Now, EmployeeId = emp.Id, VacationTypeId = id, NumberOfDays = vacationtype.Balance, Period = DateTime.Now.Year }; var vacationallocation = _mapper.Map <VacationAllocation>(allocation); await _allocationrepo.Create(vacationallocation); } return(RedirectToAction(nameof(Index))); }