public ActorDetailViewModel(INavigation navigation) { _Navigation = navigation; _peopleService = new PeopleService(); _movieParameter = new MovieParameter(); CloseModalCommand = new Command(CloseModal); }
internal async Task <List <MovieModel> > GetMovies(MovieParameter movieParameter) { var moviesList = new List <MovieModel>(); try { var resource = movieParameter.Resource; var response = await Global.Instance.BaseService.Consume <MovieParameter, ResponseListDTO <List <MovieDTO> > >(movieParameter, resource, HTTPMethodEnum.GET); moviesList = response.results.Select(movie => new MovieModel { ReleaseDate = string.IsNullOrEmpty(movie.release_date) ? "not available" : DateTime.Parse(movie.release_date).ToShortDateString(), Name = movie.title, OverView = BuildAbreviatedMovieOverView(movie.overview), Poster = movie.poster_path.BuildImageURI(), Score = movie.vote_average, Votes = movie.vote_count, Id = movie.id }).ToList(); } catch { } return(moviesList); }
internal async Task <ActorModel> GetActor(MovieParameter movieParameter) { var actorModel = new ActorModel(); try { var resource = string.Format(MoviesApiResourcesConsts.ACTOR, movieParameter.Id); var response = await Global.Instance.BaseService.Consume <MovieParameter, PersonDTO>(movieParameter, resource, HTTPMethodEnum.GET); actorModel.DOB = string.Format("Birthday: {0}", response.birthday); actorModel.DOD = string.IsNullOrEmpty(response.deathday) ? "Active" : string.Format("Death day: {0}", response.deathday); actorModel.ID = response.id; actorModel.Name = response.name; actorModel.Photo = response.profile_path.BuildImageURI(); actorModel.Bio = response.biography; actorModel.Department = string.Format("Known for: {0}", response.known_for_department); actorModel.POB = string.Format("Place of birth: {0}", response.place_of_birth); actorModel.Adult = response.adult ? "Yes":"No"; actorModel.Gender = string.Format("Gender: {0}", (response.gender.Equals(1) ? "Female" : "Male")); actorModel.Popularity = string.Format("Popularity: {0}", response.popularity); actorModel.HomePage = response.homepage; } catch { actorModel.Error = true; actorModel.ErrorMessage = "Ops, an error occurred while fetchind data from this actor"; } return(actorModel); }
public MovieDetailViewModel(INavigation navigation) { _Navigation = navigation; _movieParameter = new MovieParameter(); _movieService = new MovieService(); CloseModalCommand = new Command(CloseModal); OpenHomePageCommand = new Command <object>(OpenHomePage); }
internal async Task <MovieModel> GetMovie(MovieParameter movieParameter) { MovieModel movieModel = new MovieModel(); try { var movieresource = string.Format(MoviesApiResourcesConsts.MOVIE, movieParameter.Id); var movieID = movieParameter.Id; movieParameter.Id = null; var response = await Global.Instance.BaseService.Consume <MovieParameter, MovieDTO>(movieParameter, movieresource, HTTPMethodEnum.GET); var releaseDate = new DateTime(); DateTime.TryParse(response.release_date, out releaseDate); var releaseDateFormatted = releaseDate == DateTime.MinValue ? string.Empty : releaseDate.ToShortDateString(); movieModel.ReleaseDate = releaseDateFormatted; movieModel.Name = response.title; movieModel.OverView = response.overview; movieModel.Genres = response.genres.Select(g => new GenreModel { ID = g.id, Name = g.name }).ToList(); movieModel.Poster = response.poster_path.BuildImageURI(size: "500"); movieModel.Id = response.id; movieModel.Score = response.vote_average; movieModel.Votes = response.vote_count; movieModel.Language = response.original_language; movieModel.HomePage = string.IsNullOrEmpty(response.homepage) ? "Not available" : response.homepage; movieModel.ProducedBy = string.Format("Produced By: {0}", string.Join(", ", response.production_companies.Select(r => r.name))); movieModel.ProducedIn = string.Format("Produced In: {0}", string.Join(", ", response.production_countries.Select(r => r.name))); movieresource = string.Format(MoviesApiResourcesConsts.MOVIE_IMAGES, movieID); var imagesresponse = await Global.Instance.BaseService.Consume <MovieParameter, MovieDTO>(movieParameter, movieresource, HTTPMethodEnum.GET); if (imagesresponse.posters != null && imagesresponse.posters.Any()) { movieModel.Images.AddRange(imagesresponse.posters.Select(p => new ImageModel { Height = p.height, Width = p.width, Path = p.file_path.BuildImageURI() })); } } catch (Exception ex) { movieModel.Error = true; movieModel.ErrorMessage = ex.Message; } finally { } return(movieModel); }
public CameraCaptureViewModel(INavigation navigation) { _Navigation = navigation; _movieParameter = new MovieParameter(); _movieService = new MovieService(); Movies = new ObservableCollection <MovieModel>(); GetMovieCommand = new Command <MovieModel>(GetMovie); MovieAppearCommand = new Command <MovieModel>(MovieAppear); PullToRefreshCommand = new Command(PullToRefresh); }
public SearchActorsResultViewModel(INavigation navigation) { _Navigation = navigation; _movieParameter = new MovieParameter(); _peopleService = new PeopleService(); Actors = new ObservableCollection <ActorModel>(); GetActorCommand = new Command <ActorModel>(GetActor); ActorAppearCommand = new Command <ActorModel>(ActorAppear); PullToRefreshCommand = new Command(PullToRefresh); }
internal async Task <List <GenreModel> > GetGenres(MovieParameter movieParameter) { var genresList = new List <GenreModel>(); try { var resource = MoviesApiResourcesConsts.GENRES; var response = await Global.Instance.BaseService.Consume <MovieParameter, ResponseListDTO <List <GenreDTO> > >(movieParameter, resource, HTTPMethodEnum.GET); genresList = response.genres.Select(genre => new GenreModel { ID = genre.id, Name = genre.name }).ToList(); } catch { } return(genresList); }
internal async Task <List <ActorModel> > GetActors(MovieParameter movieParameter) { var actorList = new List <ActorModel>(); try { var resource = movieParameter.Resource; var response = await Global.Instance.BaseService.Consume <MovieParameter, ResponseListDTO <List <PeopleDTO> > >(movieParameter, resource, Enums.HTTPMethodEnum.GET); actorList = response.results.Select(people => new ActorModel { Name = people.name, Photo = people.profile_path.BuildImageURI(), ID = people.id, Popularity = string.Format("Popularity: {0}", people.popularity), Adult = string.Format("Adult: {0}", (people.adult ? "Yes" : "No")) }).ToList(); } catch { } return(actorList); }