Exemplo n.º 1
0
        public async Task <MovieInfoUiModel> MapToUiModel(MovieInfo movie)
        {
            var output = new MovieInfoUiModel
            {
                MovieTitle = movie.Title,

                Runtime    = movie.Runtime,
                Genre      = movie.Genre,
                ImdbID     = movie.ImdbID,
                Writer     = movie.Writer,
                Year       = movie.Year,
                IsFavorite = await _favoriteMoviesRepository.IsFavorite(movie.ImdbID),
            };

            try
            {
                output.Poster = new BitmapImage(new Uri(movie.Poster, UriKind.Absolute));
            }
            catch (UriFormatException)
            {
                output.Poster = new BitmapImage();
            }

            return(output);
        }
Exemplo n.º 2
0
 public MovieInfo MapToDbModel(MovieInfoUiModel uiModel) => new MovieInfo
 {
     ImdbID     = uiModel.ImdbID,
     Title      = uiModel.MovieTitle,
     Poster     = uiModel.Poster.ToString(),
     Genre      = uiModel.Genre,
     IsFavorite = uiModel.IsFavorite,
     Runtime    = uiModel.Runtime,
     Writer     = uiModel.Writer,
     Year       = uiModel.Year
 };
Exemplo n.º 3
0
 private async Task OnSaveToFavoriteExecuteAsync(MovieInfoUiModel movie)
 {
     if (movie.IsFavorite)
     {
         var modelToSave = _mapper.MapToDbModel(movie);
         await _favoriteMoviesRepository.SaveAsync(modelToSave);
     }
     else
     {
         await _favoriteMoviesRepository.DeleteAsync(movie.ImdbID);
     }
 }
        private async Task OnRemoveAsyncExecute(MovieInfoUiModel selectedMovie)
        {
            await _favoriteMoviesRepository.DeleteAsync(selectedMovie.ImdbID);

            Movies.Remove(selectedMovie);
        }