Example #1
0
        // GET: AbsenceTypeController/Details/5
        public ActionResult Details(int id)
        {
            if (!_repo.IsExist(id))
            {
                return(NotFound());
            }
            var AbsenceType = _repo.GetById(id);
            var model       = _mapper.Map <DetailsAbsenceTypeViewModel>(AbsenceType);

            return(View(model));
        }
Example #2
0
        public ActionResult SetAbsence(int id)
        {
            var AbsenceType = _absenceTypeRepo.GetById(id);
            var students    = _userManager.GetUsersInRoleAsync("Student").Result;

            foreach (var student in students)
            {
                if (_absenceAllocationRepository.CheckAllocation(id, student.Id))
                {
                    continue;
                }
                var allocation = new AbsenceAllocationViewModel
                {
                    DateCreated   = DateTime.Now,
                    StudentId     = student.Id,
                    AbsenceTypeId = id,
                    NumberOfDays  = AbsenceType.DefaultDays,
                    Period        = DateTime.Now.Year
                };
                var absenceAllocation = _mapper.Map <AbsenceAllocation>(allocation);
                _absenceAllocationRepository.Create(absenceAllocation);
            }
            return(RedirectToAction(nameof(Index)));
        }