public ActionResult UpdateRoomStatus() { IRepository repository = new CommunicationWithDataBase(); logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); return(View(rooms)); }
public ActionResult RoomReservation() { IRepository repository = new CommunicationWithDataBase(); logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); ViewData["RoomClassItems"] = FormingSelectItems.GetRoomClassRoomItems(rooms); ViewData["CountOfPlacesItems"] = FormingSelectItems.GetCurrentRoomCountOfPlacesItems(rooms); return(View(rooms)); }
public ActionResult RoomReservation(FormCollection form) { IRepository repository = new CommunicationWithDataBase(); int roomClassId = Convert.ToInt32(form["RoomClass"]); int countOfPlaces = Convert.ToInt32(form["CountOfPlaces"]); DateTime startDate = new DateTime(); DateTime endDate = new DateTime(); try { startDate = Convert.ToDateTime(form["StartDate"]); endDate = Convert.ToDateTime(form["EndDate"]); } catch { ModelState.AddModelError("DateValidationError", "Даты указаны некорректно"); logger.Error($"Ошибка. Невозможно конвертировать дату"); } if (startDate < DateTime.Now || startDate >= endDate) { ModelState.AddModelError("DateValidationError", "Даты указаны некорректно"); } if (startDate.AddDays(14) < endDate) { ModelState.AddModelError("DateValidationError", "Проживание в отеле допустимо не более 2х недель"); } if (ModelState.IsValid) { logger.Debug($"Обращение к базе данных, создание запроса на поселение"); string userLogin = User.Identity.Name; repository.CreateRequest(userLogin, roomClassId, countOfPlaces, startDate, endDate); logger.Info($"Пользователем создан новый запрос на поселение"); return(RedirectToAction("Index")); } logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); ViewData["RoomClassItems"] = FormingSelectItems.GetRoomClassRoomItems(rooms); ViewData["CountOfPlacesItems"] = FormingSelectItems.GetCurrentRoomCountOfPlacesItems(rooms); return(View()); }
public ActionResult NotProcessedRequests() { IRepository repository = new CommunicationWithDataBase(); logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); IEnumerable <SelectListItem> roomNumberItems = FormingSelectItems.GetRoomNumberItems(rooms); ViewData["RoomNumberItems"] = roomNumberItems; logger.Debug($"Обращение к базе данных, получение запросов на проживание"); List <Booking> bookings = repository.GetBookingRequests(); var notProcessedBookings = bookings.Where(b => b.BookingStatusId == 1); return(View(notProcessedBookings)); }
public ActionResult PartialRooms(FormCollection form) { IRepository repository = new CommunicationWithDataBase(); logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); List <Room> currentRooms = new List <Room>(); int roomTypeNumber = 0; logger.Debug($"Выборка нужных комнат из всех доступных"); switch (form["RoomItems"]) { case "1": roomTypeNumber = 1; currentRooms = rooms.Where(r => r.Bookings.Where(b => b.DateStart <= DateTime.Now && b.DateEnd > DateTime.Now) .Select(rn => rn.RoomNumber).ToList().Contains(r.Numder) == false && r.Availability) .ToList(); break; case "2": roomTypeNumber = 2; currentRooms = rooms.Where(r => r.Bookings.Where(b => b.DateStart <= DateTime.Now && b.DateEnd > DateTime.Now) .Select(rn => rn.RoomNumber).ToList().Contains(r.Numder) && r.Availability).ToList(); break; case "3": roomTypeNumber = 3; currentRooms = rooms.Where(r => r.Bookings.Where(b => b.DateStart > DateTime.Now) .Select(rn => rn.RoomNumber).ToList().Contains(r.Numder) && r.Availability).ToList(); break; case "4": roomTypeNumber = 4; currentRooms = rooms.Where(r => r.Availability == false).ToList(); break; } ViewData["RoomTypeNumber"] = roomTypeNumber; return(View(currentRooms)); }
public ActionResult AllRooms() { IRepository repository = new CommunicationWithDataBase(); List <SelectListItem> roomItems = new List <SelectListItem>() { new SelectListItem() { Text = "Свободны", Value = "1" }, new SelectListItem() { Text = "Заняты", Value = "2" }, new SelectListItem() { Text = "Забронированы", Value = "3" }, new SelectListItem() { Text = "Недоступны", Value = "4" }, }; ViewData["RoomItems"] = roomItems; logger.Debug($"Обращение к базе данных, получение комнат"); List <Room> rooms = repository.GetAllRooms(); ViewData["RoomClassItems"] = FormingSelectItems.GetRoomClassRoomItems(rooms); return(View(rooms)); }