private void AddScreeningButton_Click(object sender, EventArgs e) { try { string movieName = GetMovieName(movieComboBox.Text); int year = GetMovieYear(movieComboBox.Text); DateTime getDate = DateCalendar.SelectionRange.Start; string date = getDate.Day.ToString() + " " + getDate.ToString("MMM") + " " + getDate.DayOfWeek.ToString(); DateTime getTime = TimePicker.Value; string time = getTime.ToString("hh") + ":" + getTime.ToString("mm") + " " + getTime.ToString("tt", CultureInfo.InvariantCulture); DateTime startTime = ScreeningService.GetDateTimeFromDateAndTime(date, time); byte auditoriumNumber = byte.Parse(auditoriumComboBox.Text); int auditoriumId = AuditoriumService.GetAuditoriumId(auditoriumNumber, this.cinema.Id); int movieId = MovieService.GetMovieId(movieName, year); ScreeningValidator.ValidateScreeningTimeAvailable(startTime, auditoriumId, movieName, year); ScreeningService.AddScreening(auditoriumId, movieId, startTime); MessageBox.Show("Screening added successfully!"); Cinema cinema = CinemaService.GetCinemaWithScreenings(this.cinema.Id); SelectScreeningForm screeningsForm = new SelectScreeningForm(cinema); screeningsForm.TopLevel = false; screeningsForm.AutoScroll = true; this.Hide(); ((Button)sender).Parent.Parent.Controls.Add(screeningsForm); screeningsForm.Show(); } catch (Exception exception) { MessageBox.Show("Add screening failed!"); } }
public static void ImportScreening(ScreeeningDto screeningDto) { byte auditoriumNumber = screeningDto.AuditoriumNumber; string cinemaTown = screeningDto.CinemaTown; TownValidator.CheckTownExisting(cinemaTown); int townId = TownService.GetTownId(cinemaTown); string cinemaName = screeningDto.CinemaName; CinemaValidator.CheckCinemaExisting(cinemaName, townId); int cinemaId = CinemaService.GetCinemaId(cinemaName, townId); AuditoriumValidator.CheckAuditoriumExists(auditoriumNumber, cinemaId, cinemaName); string movieName = screeningDto.MovieName; int movieReleaseYear = screeningDto.MovieReleaseYear; MovieValidator.CheckMovieExists(movieName, movieReleaseYear); int auditoriumId = AuditoriumService.GetAuditoriumId(auditoriumNumber, cinemaId); DateTime date = screeningDto.Date; ScreeningValidator.ValidateScreeningDoesntExist(auditoriumId, date); int movieId = MovieService.GetMovieId(movieName, movieReleaseYear); ScreeningService.AddScreening(auditoriumId, movieId, date); Console.WriteLine(string.Format(Constants.ImportSuccessMessages.ScreeningAddedSuccess, auditoriumNumber, cinemaName)); }
private void EditScreeningButton_Click(object sender, EventArgs e) { try { DateTime getDate = DateCalendar.SelectionRange.Start; string date = getDate.Day.ToString() + " " + getDate.ToString("MMM") + " " + getDate.DayOfWeek.ToString(); DateTime getTime = TimePicker.Value; string time = getTime.ToString("hh") + ":" + getTime.ToString("mm") + " " + getTime.ToString("tt", CultureInfo.InvariantCulture); DateTime startTime = ScreeningService.GetDateTimeFromDateAndTime(date, time); ScreeningValidator.ValidateScreeningAvailable(screening.Id, startTime); ScreeningService.UpdateScreening(screening.Id, startTime); MessageBox.Show("Screening updated successfully!"); Cinema cinema = CinemaService.GetCinemaWithScreenings(screening.Auditorium.CinemaId); SelectScreeningForm screeningsForm = new SelectScreeningForm(cinema); screeningsForm.TopLevel = false; screeningsForm.AutoScroll = true; this.Hide(); ((Button)sender).Parent.Parent.Controls.Add(screeningsForm); screeningsForm.Show(); } catch (Exception exception) { MessageBox.Show("Screening updated failed!"); } }
public EditScreening(Screening screening) { this.screeningService = new ScreeningService(); this.screeningValidator = new ScreeningValidator(screeningService); this.cinemaService = new CinemaService(); this.screening = screening; InitializeComponent(); }
public AddScreeningForm(Cinema cinema) { this.movieService = new MovieService(); this.auditoriumService = new AuditoriumService(); this.cinemaService = new CinemaService(); this.screeningService = new ScreeningService(); this.screeningValidator = new ScreeningValidator(screeningService); this.cinema = cinema; InitializeComponent(); }
public ScreeningImportService() { this.auditoriumService = new AuditoriumService(); this.cinemaService = new CinemaService(); this.auditoriumValidator = new AuditoriumValidator(auditoriumService); this.cinemaValidator = new CinemaValidator(cinemaService); this.movieService = new MovieService(); this.movieValidator = new MovieValidator(movieService); this.townService = new TownService(); this.townValidator = new TownValidator(townService); this.screeningService = new ScreeningService(); this.screeningValidator = new ScreeningValidator(screeningService); }