コード例 #1
0
        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;
        }
コード例 #2
0
        public void Delete(Showtime showtime)
        {
            var executor = new CommandExecutor("dbo.DeleteShowtime", connectionString);
            executor.SetParam("@Id", showtime.Id, SqlDbType.Int);

            executor.ExecuteCommand(true).ThrowIfException();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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";
        }
コード例 #5
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;
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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);
                }
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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();
        }
コード例 #10
0
 public void GoToShowtimeDetails(Showtime showtime)
 {
     Window.NavigateToAuditoriumMap(showtime);
 }
コード例 #11
0
 public void NavigateToCheckoutPage(Showtime showtime, IEnumerable<AuditoriumSeat> seats)
 {
     var checkoutPage = new CheckoutPage(showtime, seats.ToList());
     DataContext = checkoutPage;
 }
コード例 #12
0
 public void NavigateToAuditoriumMap(Showtime showtime)
 {
     var auditoriumMapPage = new AuditoriumMapPage(showtime);
     DataContext = auditoriumMapPage;
 }