//Страница бронирования мест //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()); }
private void CreateDataAboutFilm(int id) { //Информация о выбранном дне сохраняется в HttpContext.Items["CurrentDay"] //По умолчанию равен дате сегодня var timeNow = DateTime.Now; var currentDay = timeNow.Date; //new DateTime(timeNow.Year,timeNow.Month, timeNow.Day); if (Request.Query.ContainsKey("schedule_date")) { currentDay = DateTime.ParseExact( Request.Query["schedule_date"], "dd.MM.yyyy", CultureInfo.InvariantCulture); } HttpContext.Items["CurrentDay"] = currentDay; var film = FilmViewModelDAO.GetFilms($"WHERE id = {id}", false).FirstOrDefault(); FilmViewModel = film; FilmViewModel.Actors = FilmViewModelDAO.GetActorsByFilmId(FilmViewModel.Id); FilmViewModel.Producers = FilmViewModelDAO.GetProducersByFilmId(FilmViewModel.Id); FilmViewModel.Country = FilmViewModelDAO.GetCounrtyById(FilmViewModel.CountryId); FilmViewModel.Reviews = FilmViewModelDAO.GetReviewByFilmId(FilmViewModel.Id); FilmViewModel.Schedule = ScheduleDAO.GetSchedule($"id_movie={id} AND date::DATE = '{currentDay:yyyy-MM-dd}'"); }
protected void btnGuardar_Click(object sender, EventArgs e) { string idstr = boxID.Text; try { User usr = new User(); if (!String.IsNullOrEmpty(idstr)) { usr.Id = int.Parse(idstr); } usr.Name = boxNombre.Text; usr.Appat = boxApPat.Text; usr.Apmat = boxApMat.Text; usr.Email = boxEmail.Text; usr.Institution = InstitutionDAO.GetInstitution(int.Parse(selInstitution.SelectedValue)); usr.Schedule = ScheduleDAO.GetSchedule(int.Parse(Request.Form["selSchedule"])); usr.Username = boxUsername.Text; usr.Password = boxPassword.Text; User sUser = (User)Session["user"]; if (sUser.Type == "manager") { usr.Type = "agent"; } else { usr.Type = Request.Form["selType"]; } if (String.IsNullOrEmpty(idstr)) //new { UserDAO.AddUser(usr); } else //update { UserDAO.ModUser(usr); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } Response.Redirect("~/UserList"); Context.ApplicationInstance.CompleteRequest(); }
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()); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { User sUser = (User)Session["user"]; if (sUser == null) { Response.Redirect("~/Login"); } string idstr = Request["Id"]; if (String.IsNullOrEmpty(idstr)) //new schedule { btnBorrar.Visible = false; lblId.Visible = false; boxID.Visible = false; } else //load schedule { try { boxID.Enabled = false; Schedule schedule = ScheduleDAO.GetSchedule(int.Parse(idstr)); boxID.Text = schedule.Id.ToString(); boxNombre.Text = schedule.Name; boxDescripcion.Text = schedule.Description; boxLunesin.Text = schedule.Lunesin; boxLunesout.Text = schedule.Lunesout; boxMartesin.Text = schedule.Martesin; boxMartesout.Text = schedule.Martesout; boxMiercolesin.Text = schedule.Miercolesin; boxMiercolesout.Text = schedule.Miercolesout; boxJuevesin.Text = schedule.Juevesin; boxJuevesout.Text = schedule.Juevesout; boxViernesin.Text = schedule.Viernesin; boxViernesout.Text = schedule.Viernesout; boxSabadoin.Text = schedule.Sabadoin; boxSabadoout.Text = schedule.Sabadoout; boxDomingoin.Text = schedule.Domingoin; boxDomingoout.Text = schedule.Domingoout; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); Debug.WriteLine(ex.Message); } } List <Institution> institutions = InstitutionDAO.GetInstitutions(); int ins_fk = 1; if (!String.IsNullOrEmpty(Request["Id"])) { ins_fk = ScheduleDAO.GetSchedule(int.Parse(boxID.Text)).Fk_institution; } if (sUser.Type == "admin") { foreach (Institution ins in institutions) { if (!String.IsNullOrEmpty(Request["Id"]) && ins.Id == ins_fk) //not postback, requesting id info, { selInstitution.Items.Add(new ListItem(ins.Id + " - " + ins.Name, ins.Id.ToString())); selInstitution.SelectedValue = ins.Id.ToString(); //selInstitution.InnerText += ("<option value=\"" + ins.Id + "\" selected>" + ins.Id + "-" + ins.Name + "</option>"); } else { //selInstitution.InnerText += ("<option value=\"" + ins.Id + "\">" + ins.Id + "-" + ins.Name + "</option>"); selInstitution.Items.Add(new ListItem(ins.Id + " - " + ins.Name, ins.Id.ToString())); } } } else if (sUser.Type == "manager") { selInstitution.Items.Add(new ListItem(sUser.Institution.Id + " - " + sUser.Institution.Name, sUser.Institution.Id.ToString())); //selInstitution.InnerText += ("<option value=\"" + sUser.Institution.Id + "\" selected>" + sUser.Institution.Name + "</option>"); } } }