Exemplo n.º 1
0
        public void Refresh()
        {
            Repertoires.Clear();
            var location = _appSettings.Location;

            if (location != null)
            {
                var cinemas = Task.Run(() => _dataStorage.GetCinemaRepertoires(location)).Result;
                foreach (var cinema in cinemas)
                {
                    var color       = CinemaHelper.TextColor((CinemaType)cinema.CinemaType);
                    var displayName = String.Format("{0} {1}", cinema.CinemaName, cinema.CinemaCity);
                    var shortName   = String.Format("{0}{1}", cinema.CinemaName.Substring(0, 2), cinema.CinemaCity.Substring(0, 1));
                    var group       = new Group <MovieShows>(color, displayName, shortName);
                    foreach (var movie in cinema.Movies)
                    {
                        if (_filter.Check(movie))
                        {
                            var movieShow = new MovieShows(cinema.Id, movie.Id, group.DisplayName, movie.Title, movie.Genres, movie.Shows, movie.Rating);
                            group.Add(movieShow);
                        }
                    }

                    Repertoires.Add(group);
                }
            }
        }
Exemplo n.º 2
0
        public MovieViewModel(IDataStorage dataStorage, MovieShows movieShow)
        {
            _dataStorage = dataStorage;
            _cinema      = Task.Run(() => _dataStorage.GetCinema(movieShow.Cinema)).Result;
            Genres       = movieShow.Genres;
            Shows        = movieShow.Shows;

            var movie   = Task.Run(() => _dataStorage.GetMovie(movieShow.MovieId)).Result;
            var ratings = Task.Run(() => _dataStorage.GetRating(movieShow.CinemaId, movieShow.MovieId)).Result;

            foreach (var rating in ratings)
            {
                CleanlinessRating += rating.Cleanliness;
                ScreenRating      += rating.Screen;
                SeatsRating       += rating.Comfort;
                SnacksRating      += rating.Snacks;
                SoundRating       += rating.Sound;
            }

            CleanlinessRating = CleanlinessRating / ratings.Count;
            ScreenRating     /= ratings.Count;
            SeatsRating      /= ratings.Count;
            SnacksRating     /= ratings.Count;
            SoundRating      /= ratings.Count;
            AverageRating     = (CleanlinessRating + ScreenRating + SeatsRating + SnacksRating + SoundRating) / 5;

            Cast        = movie.Cast;
            Description = movie.Storyline;
            Director    = movie.Director;
            Title       = movie.OriginalName;

            OpenWebsite = new Command(VisitWebsite);
            OpenYoutube = new Command(VisitYoutube);
        }
Exemplo n.º 3
0
        private void ProcessMovies(Cinema cinema, string cinemaName, CinemaType cinemaType)
        {
            var textColor = CinemaColor(cinemaType);
            var group     = new Group <MovieShows>(textColor, cinemaName, cinema.Name.Substring(0, 1) + cinema.City.Substring(0, 2));

            foreach (SimpleMovie movie in cinema.MoviesPlayed)
            {
                if (_filterService.IsActive)
                {
                    if (!_filterService.Check(movie))
                    {
                        continue;
                    }
                }

                string shows = "";
                foreach (var show in movie.Shows)
                {
                    if (show.ShowDate.Date.Equals(DateTime.Today))
                    {
                        shows = shows + show.Start + ", ";
                    }
                }

                string genre = null;
                if (movie.Genre != null)
                {
                    if (movie.Genre.Count > 0)
                    {
                        genre = movie.Genre[0];
                    }
                }

                var             showData = new BasicShowData(cinema.IdCinema, movie.Id, cinemaName, movie.AverageRating);
                MvxAsyncCommand command  = new MvxAsyncCommand(async() =>
                {
                    await _navigationService.Navigate <MovieViewModel, BasicShowData>(showData);
                });

                var movieShows = new MovieShows(movie.Name, genre, shows, movie.AverageRating, command);
                group.Add(movieShows);
            }

            if (group.Count != 0)
            {
                Repertoires.Add(group);
            }
        }
Exemplo n.º 4
0
        public ShowPage(MovieShows movieShows)
        {
            var moviePage = new MoviePage(movieShows)
            {
                Title = "Movie"
            };

            var cinemaPage = new CinemaPage(movieShows.Cinema)
            {
                Title = "Cinema"
            };

            InitializeComponent();
            Children.Add(moviePage);
            Children.Add(cinemaPage);
        }
Exemplo n.º 5
0
 public MovieViewModel(MovieShows movieShow) : this(DependencyService.Get <IDataStorage>(), movieShow)
 {
 }
Exemplo n.º 6
0
 public MoviePage(MovieShows movieShows)
 {
     BindingContext = new MovieViewModel(movieShows);
     InitializeComponent();
 }