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) { 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)); }