public ShowtimeEditorWindowViewModel(ShowtimeEditorWindow view, Showtime showtime, MovieRepository movieRepository, ShowtimeRepository showtimeRepository) { if (showtime == null) { CreateMode = true; showtime = new Showtime(); } this.view = view; this.movieRepository = movieRepository; this.showtimeRepository = showtimeRepository; Showtime = showtime; Movies = movieRepository.GetMovies().ToList(); Auditoriums = showtimeRepository.GetAuditoriums().ToList(); if (CreateMode) return; var movie = Movies.FirstOrDefault(_ => _.Id == showtime.Movie.Id); view.SelectedMovieIndex = Movies.IndexOf(movie); var auditorium = Auditoriums.FirstOrDefault(_ => _.Id == showtime.Auditorium.Id); view.SelectedAuditoriumIndex = Auditoriums.IndexOf(auditorium); view.Time = showtime.Time; }
public void Delete(Showtime showtime) { var executor = new CommandExecutor("dbo.DeleteShowtime", connectionString); executor.SetParam("@Id", showtime.Id, SqlDbType.Int); executor.ExecuteCommand(true).ThrowIfException(); }
public CheckoutPageViewModel(CheckoutPage view, TicketRepository repository, Showtime showtime, List<AuditoriumSeat> seats) { this.repository = repository; this.showtime = showtime; this.seats = seats; this.view = view; Total = showtime.Price*seats.Count; ArrowAnimatedBrush = new SolidColorBrush(); }
public AuditoriumMapPageViewModel(AuditoriumMapPage view, TicketRepository repository, Showtime showtime) { this.view = view; this.repository = repository; this.showtime = showtime; seats = new List<AuditoriumSeat>(); var occupiedSeats = repository.GetOccupiedSeats(showtime.Id).ToList(); Auditorium = new AuditoriumView(showtime.Auditorium, occupiedSeats); Auditorium.PropertyChanged += SelectionChanged; Total = "0"; }
public AuditoriumMapPage(Showtime showtime) { InitializeComponent(); var connectionString = ConnectionStringBuilder.Build( Settings.Default.server, Settings.Default.database, Settings.Default.user, Settings.Default.password); var repository = new TicketRepository(connectionString); viewModel = new AuditoriumMapPageViewModel(this, repository, showtime); DataContext = viewModel; }
public CheckoutPage(Showtime showtime, List<AuditoriumSeat> seats) { InitializeComponent(); var connectionString = ConnectionStringBuilder.Build( Settings.Default.server, Settings.Default.database, Settings.Default.user, Settings.Default.password); var repository = new TicketRepository(connectionString); viewModel = new CheckoutPageViewModel(this, repository, showtime, seats); DataContext = viewModel; SetUpAnimations(); }
public void Delete(Showtime showtime) { var result = MessageBox.Show( string.Format(Resources.DeleteShowtimeConfirmatonText, showtime.Time.ToLongDateString(), showtime.Movie.Title), Resources.DeleteConfirmationCaption, MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { try { repository.Delete(showtime); RetrieveData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void OpenEditor(Showtime showtime) { try { if (showtime != null) { showtime = showtime.Clone(); } var editor = new ShowtimeEditorWindow(showtime); var result = editor.ShowDialog(); if (result.HasValue && result.Value) { RetrieveData(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Save(Showtime showtime, bool update) { CommandExecutor executor; if (update) { executor = new CommandExecutor("dbo.UpdateShowtime", connectionString); executor.SetParam("@Id", showtime.Id, SqlDbType.Int); } else { executor = new CommandExecutor("dbo.CreateShowtime", connectionString); } executor.SetParam("@MovieId", showtime.Movie.Id, SqlDbType.Int); executor.SetParam("@AuditoriumId", showtime.Auditorium.Id, SqlDbType.Int); executor.SetParam("@ShowtimeDate", showtime.Time, SqlDbType.DateTime); executor.SetParam("@Price", showtime.Price, SqlDbType.Money); executor.SetParam("@ThreeDee", showtime.ThreeDee, SqlDbType.Bit); executor.ExecuteCommand(true).ThrowIfException(); }
public void GoToShowtimeDetails(Showtime showtime) { Window.NavigateToAuditoriumMap(showtime); }
public void NavigateToCheckoutPage(Showtime showtime, IEnumerable<AuditoriumSeat> seats) { var checkoutPage = new CheckoutPage(showtime, seats.ToList()); DataContext = checkoutPage; }
public void NavigateToAuditoriumMap(Showtime showtime) { var auditoriumMapPage = new AuditoriumMapPage(showtime); DataContext = auditoriumMapPage; }