private void AddMovieClick(object data = null) { ObservableCollection <CinemaHall> cinemaHalls; try { cinemaHalls = JsonFileHelper.JsonDeserialization <CinemaHall>("Database of Cinemas/cinemas"); } catch (Exception) { cinemaHalls = new ObservableCollection <CinemaHall>(); } if (cinemaHalls.FirstOrDefault(ch => ch.Movie.ImdbID == Movie.ImdbID) != null) { System.Windows.MessageBox.Show("This movie already exists.", "Mosaviena"); return; } cinemaHalls.Add(new CinemaHall { Movie = this.Movie }); JsonFileHelper.JsonSerialization(cinemaHalls, "Database of Cinemas/cinemas"); System.Windows.MessageBox.Show($"Movie \"{Movie.Title}\" added to cinema successfully.", "Mosaviena"); }
private void PutMovieToCinemaButtonClick(object data) { if (data is Movie movie) { System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"Do you want to add \"{movie.Title}\" to cinema ?", "Mosaviena", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question); if (result == System.Windows.MessageBoxResult.Yes) { try { CinemaHalls = JsonFileHelper.JsonDeserialization <CinemaHall>("Database of Cinemas/cinemas"); } catch (Exception) { CinemaHalls = new ObservableCollection <CinemaHall>(); } if (CinemaHalls.FirstOrDefault(cm => cm.Movie.ImdbID == movie.ImdbID) != null) { System.Windows.MessageBox.Show($"You already add this movie to cinema.", "Mosaviena"); return; } CinemaHalls.Add(new CinemaHall { Movie = movie }); JsonFileHelper.JsonSerialization <CinemaHall>(CinemaHalls, "Database of Cinemas/cinemas"); } System.Windows.MessageBox.Show($"Operation {result} done successfully.", "Mosaviena"); } }
public LocationViewModel() { string APIKey = ConfigurationManager.AppSettings["BingMapAPIKEY"]; BingMapServices.Provider = new ApplicationIdCredentialsProvider(APIKey); TotalBudget = BinaryFileHelper.BinaryDeserialization("Total Budget"); Locations = JsonFileHelper.JsonDeserialization <Models.Location>("Cinema Locations/locations"); BackCommand = new RelayCommand(BackClick); }
public AdminSideCinemaViewModel() { try { CinemaHalls = JsonFileHelper.JsonDeserialization <CinemaHall>("Database of Cinemas/cinemas"); } catch (Exception) { CinemaHalls = new ObservableCollection <CinemaHall>(); } AddCinemaCommand = new RelayCommand(AddCinemaClick); }
public MovieTemplateViewModel() { try { Movies = JsonFileHelper.JsonDeserialization <Movie>("Database of Liked Movies/movies"); } catch (Exception) { Movies = new ObservableCollection <Movie>(); } LikeCommand = new RelayCommand(LikeClick); ImageMouseLeftCommand = new RelayCommand(ImageMouseLeftClick); }
public AdminLoginViewModel() { try { Admins = JsonFileHelper.JsonDeserialization <Admin>("Database of Admins/admins"); } catch (Exception) { Admins = new ObservableCollection <Admin>(); } SubmitCommand = new RelayCommand(SubmitClick); BackCommand = new RelayCommand(BackClick); }
private void SetRecognizerDatas() { ObservableCollection <string> grammers = JsonFileHelper.JsonDeserialization <string>("Speech Commands/commands"); _recognizer.SetInputToDefaultAudioDevice(); GrammarBuilder grammerBuilder = new GrammarBuilder(); grammerBuilder.Append(new Choices(grammers.ToArray()), 1, 11); _recognizer.LoadGrammarAsync(new Grammar(grammerBuilder)); _recognizer.SpeechRecognized += Default_SpeechRecognized; _recognizer.RecognizeAsync(RecognizeMode.Multiple); }
public LikedMovieViewModel() { try { Movies = JsonFileHelper.JsonDeserialization <Movie>("Database of Liked Movies/movies"); List <Movie> sortedMovies = Movies.OrderByDescending(movie => movie.LikeCount).ToList(); Movies.Clear(); for (int i = 0; i < sortedMovies.Count; i++) { Movies.Add(sortedMovies[i]); } } catch (Exception) { Movies = new ObservableCollection <Movie>(); } PutMovieToCinemaCommand = new RelayCommand(PutMovieToCinemaButtonClick); }
private void FindLikedMovieInAllLikedMoviesAndReplaceCurrentMovie() { try { AllLikedMovies = JsonFileHelper.JsonDeserialization <Movie>("Database of Liked Movies/movies"); } catch (Exception) { } Movie movie = AllLikedMovies?.FirstOrDefault(m => m.ImdbID == Movies[_currentNumber].ImdbID); if (_isGuestEntered) { (ViewModel as MovieTemplateViewModel).Movie = movie ?? Movies[_currentNumber]; } else { (ViewModel as CinemaTemplateViewModel).Movie = movie ?? Movies[_currentNumber]; } }
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."); } }