// GET: LeaveTypes/Details/5
        public ActionResult Details(int id)
        {
            if (!_repo.IsExists(id))
            {
                return(NotFound());
            }
            LeaveType         leaveType         = _repo.FindById(id);
            DetailLeaveTypeVM detailLeaveTypeVM = _mapper.Map <DetailLeaveTypeVM>(leaveType);

            return(View(detailLeaveTypeVM));
        }
Example #2
0
        public ActionResult SetLeave(int id)
        {
            var leavetype = _leaverepo.FindById(id);
            var employees = _userManager.GetUsersInRoleAsync("Employee").Result;

            foreach (var emp in employees)
            {
                if (_leaveallocationrepo.CheckLeaveAllocation(emp.Id, id))
                {
                    continue;
                }
                var allocation = new LeaveAllocationVM
                {
                    DateCreated  = DateTime.Now,
                    EmployeeId   = emp.Id,
                    LeaveTypeId  = id,
                    NumberOfDays = leavetype.DefaultDays,
                    Period       = DateTime.Now.Year
                };
                var leaveallocation = _mapper.Map <LeaveAllocation>(allocation);
                _leaveallocationrepo.Create(leaveallocation);
            }
            return(RedirectToAction(nameof(Index)));
        }