예제 #1
0
        // GET: RoomType/Details/5
        public ActionResult Details(int id)
        {
            if (!_repo.isExists(id))
            {
                return(NotFound());
            }
            var roomtype = _repo.FindById(id);
            var model    = _mapper.Map <RoomTypeViewModel>(roomtype);

            return(View(model));
        }
예제 #2
0
        public ActionResult SetRoom(int id)
        {
            var roomtype  = _roomrepo.FindById(id);
            var employees = _userManager.GetUsersInRoleAsync("Employee").Result;

            foreach (var emp in employees)
            {
                if (_bookrepo.CheckAllocation(id, emp.Id))
                {
                    continue;
                }
                var allocation = new BookingViewModel
                {
                    // BookingDate is the same as DateCreated
                    BookingDate  = DateTime.Now,
                    EmployeeId   = emp.Id,
                    RoomTypeId   = id,
                    NumberOfDays = roomtype.DefaultDays,
                    Period       = DateTime.Now.Year
                };
                var roomallocation = _mapper.Map <Booking>(allocation);
                _bookrepo.Create(roomallocation);
            }
            return(RedirectToAction(nameof(Index)));
        }