Пример #1
0
        //Страница бронирования мест
        //Id - это id сеанса(Schedule)
        public IActionResult OnGet(int id)
        {
            Id = id;
            //Не авторизован - на главную станицу
            if (!_authService.IsAuthenticated)
            {
                return(Redirect(Url.Content("~/")));
            }
            var schedule = ScheduleDAO.GetSchedule($"id_schedule = {id}").FirstOrDefault();

            schedule.Hall = ScheduleDAO.GetHallByScheduleId(id);

            var bookings = BookingDAO.GetBookingByScheduleId(id);

            foreach (var booking in bookings)
            {
                booking.Schedule = schedule;
            }

            BookingPageViewModel = new BookingPageViewModel
            {
                //Передаем сеанс с указаным id
                Schedule = schedule,
                //Передаем все бронирования на этот сеанс
                BookingsInSchedule = bookings
            };
            return(Page());
        }
Пример #2
0
 public IActionResult OnGet(int id)
 {
     UserViewModel          = UserDAO.GetUserById(id);
     UserViewModel.Bookings = BookingDAO.GetBookingsByUserId(id);
     foreach (var booking in UserViewModel.Bookings)
     {
         booking.Schedule      = ScheduleDAO.GetSchedule($"id_schedule = {booking.ScheduleId}").FirstOrDefault();
         booking.Schedule.Hall = ScheduleDAO.GetHallByScheduleId(booking.Schedule.Id);
         booking.Schedule.Film = FilmViewModelDAO.GetFilms($"WHERE id = {booking.Schedule.FilmId}", false).FirstOrDefault();
         if (booking.Row == 0)
         {
             booking.Schedule.PricePerSeat /= 2;
         }
         else if (booking.Row == booking.Schedule.Hall.SeatsRowCount.Length - 1)
         {
             booking.Schedule.PricePerSeat = Math.Round(booking.Schedule.PricePerSeat * (decimal)1.2);
         }
     }
     return(Page());
 }