示例#1
0
        public static IEnumerable <AddSavedMovieModel> Map(PagedList <MovieJMDBApi> movies, long currentUserId)
        {
            List <AddSavedMovieModel> moviesToReturn = new List <AddSavedMovieModel>();

            foreach (var movie in movies)
            {
                var movieModel = new AddSavedMovieModel
                {
                    Id       = movie.Id,
                    Name     = movie.Name,
                    Poster   = movie.Poster,
                    UserId   = currentUserId,
                    Actors   = movie.MovieDetailsJMDBApi.Actors,
                    Genre    = movie.MovieDetailsJMDBApi.Genre,
                    Duration = movie.MovieDetailsJMDBApi.Duration,
                    Year     = movie.MovieDetailsJMDBApi.Year,
                    Country  = movie.MovieDetailsJMDBApi.Country,
                    Director = movie.MovieDetailsJMDBApi.Director
                };

                moviesToReturn.Add(movieModel);
            }

            return(moviesToReturn);
        }
示例#2
0
 public static MovieJMDBApi Map(AddSavedMovieModel movieModel)
 {
     return(new MovieJMDBApi
     {
         Id = movieModel.Id,
         Name = movieModel.Name,
         Poster = movieModel.Poster,
         MovieDetailsJMDBApi = new MovieDetailsJMDBApi
         {
             Actors = movieModel.Actors,
             Genre = movieModel.Genre,
             Duration = movieModel.Duration,
             Year = movieModel.Year,
             Country = movieModel.Country,
             Name = movieModel.Name,
             Director = movieModel.Director
         }
     });
 }
示例#3
0
        public object AddSavedMovie([FromBody] AddSavedMovieModel savedMovieModel)
        {
            if (savedMovieModel.UserId != CurrentUser.Id)
            {
                return(BadRequest($"Movie can be added only for current user: {CurrentUser.Name} {CurrentUser.Surname}({CurrentUser.Mail})"));
            }

            var movieToReturn = facadeSavedMovies.AddSavedMovie(savedMovieModel.UserId, savedMovieModel);

            var links = CreateLinksForMovie(movieToReturn.UserId, movieToReturn.Id);

            var addedMovie = movieToReturn.ShapeData(null)
                             as IDictionary <string, object>;

            addedMovie.Add("links", links);

            return(new
            {
                addedMovie
            });
        }
示例#4
0
        public AddSavedMovieModel AddSavedMovie(long userId, AddSavedMovieModel addModel)
        {
            var savedMovie = SavedMoviesManager.Add(userId, Mapper.Mapper.Map(addModel));

            return(Mapper.Mapper.MapAdd(savedMovie, userId));
        }