private void BuyClick(object data = null) { int allFullSitsCount = CinemaHall.Sits.Count(sit => sit.IsFull); int guestBuyTicketCount = allFullSitsCount - FullSitsCount; if (guestBuyTicketCount == 0) { MessageBox.Show("You didn't choose any sit.", "Mosaviena"); return; } MessageBoxResult result = MessageBox.Show($"Do You want to buy cinema ticket(s) to {CinemaHall.Movie.Title} ?\nYour payment equals to {CinemaHall.Movie.ImdbRating * guestBuyTicketCount} $", "Mosaviena", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { CinemaHall.FullSitsCount = allFullSitsCount; MessageBox.Show($"Operation {result} done successfully.", "Mosaviena"); decimal totalBudget = BinaryFileHelper.BinaryDeserialization("Total Budget"); totalBudget = totalBudget + (decimal)(CinemaHall.Movie.ImdbRating * guestBuyTicketCount); BinaryFileHelper.BinarySerialization(totalBudget, "Total Budget"); StarViewModel starViewModel = new StarViewModel(); StarWindow starView = new StarWindow { DataContext = starViewModel }; starView.ShowDialog(); JsonFileHelper.JsonSerialization <CinemaHall>(CinemaHalls, "Database of Cinemas/cinemas"); PdfFileHelper.WritePaymentToFile( Tuple.Create(CinemaHall.Movie, CinemaHall.Movie.ImdbRating * guestBuyTicketCount, starViewModel.RatingNumber), $"{PdfFileHelper.ConvertFileNameToAcceptableFileName(CinemaHall.Movie.Title)}"); GuestBuyTicketViewModel guestBuyTicketViewModel = new GuestBuyTicketViewModel(CinemaHalls); GuestBuyTicketView guestBuyTicketView = new GuestBuyTicketView { DataContext = guestBuyTicketViewModel }; ViewController.SecondView.Content = guestBuyTicketView; } }
private void BackClick(object data = null) { for (int i = 0; i < EmptySitsIndexes.Count; i++) { CinemaHall.Sits[EmptySitsIndexes[i]].IsFull = false; } GuestBuyTicketViewModel guestBuyTicketViewModel = new GuestBuyTicketViewModel(CinemaHalls); GuestBuyTicketView guestBuyTicketView = new GuestBuyTicketView { DataContext = guestBuyTicketViewModel }; ViewController.SecondView.Content = guestBuyTicketView; }
private void CinemaClick(object data = null) { try { ObservableCollection <CinemaHall> cinemaHalls = JsonFileHelper.JsonDeserialization <CinemaHall>("Database of Cinemas/cinemas"); GuestBuyTicketViewModel guestBuyTicketViewModel = new GuestBuyTicketViewModel(cinemaHalls); GuestBuyTicketView guestBuyTicketView = new GuestBuyTicketView { DataContext = guestBuyTicketViewModel }; ViewController.SecondView.Content = guestBuyTicketView; HomeButtonColor = Brushes.White; TheaterButtonColor = Brushes.Green; } catch (Exception) { MessageBox.Show("There is no cinema right now."); } }