コード例 #1
0
        // GET: LeaveType/Details/5
        public ActionResult Details(int id)
        {
            if (!_repository.exists(id))
            {
                return(NotFound());
            }

            var leaveTypeDetails = _repository.FindById(id);
            var model            = _mapper.Map <LeaveTypeModel>(leaveTypeDetails);

            return(View(model));
        }
コード例 #2
0
        public ActionResult AllocateToEmployees(int id)
        {
            var leaveType = _repository.FindById(id);
            var employees = _userManager.GetUsersInRoleAsync("Employee").Result;

            foreach (var emp in employees)
            {
                LeaveAllocationModel model = new LeaveAllocationModel
                {
                    leaveTypeId  = leaveType.Id,
                    EmployeeId   = emp.Id,
                    NumberOfDays = leaveType.NumberOfDays,
                    Year         = DateTime.Now.Year
                };
                var model2 = model;
                var leaveAllocationCreate = _mapper.Map <LeaveAllocation>(model2);
                _repo.Create(leaveAllocationCreate);
            }

            return(RedirectToAction(nameof(Index)));
        }