public static MovieLikeModel ToMovieLikeModel(this MovieLike movieLike)
 {
     return(new MovieLikeModel()
     {
         Id = movieLike.Id,
         UserId = movieLike.UserId,
         MovieId = movieLike.MovieId
     });
 }
예제 #2
0
 private static MovieLikeModel ConvertToMovieLikeModel(MovieLike x)
 {
     return(new MovieLikeModel
     {
         Id = x.Id,
         RecipeId = x.MovieId,
         UserId = x.UserId,
         Status = x.Status,
     });
 }
예제 #3
0
        private MovieLike CreateNewMovieDisLike(int movieId, int userId)
        {
            MovieLike movieDisLike = new MovieLike();

            movieDisLike.Status      = false;
            movieDisLike.MovieId     = movieId;
            movieDisLike.UserId      = userId;
            movieDisLike.DateCreated = DateTime.Now;
            return(movieDisLike);
        }
예제 #4
0
        public void Add(int movieId, int userId)
        {
            var like = _movieLikesRepository.Get(movieId, userId);

            if (like == null)
            {
                var newLike = new MovieLike();
                newLike.MovieId = movieId;
                newLike.UserId  = userId;
                _movieLikesRepository.Add(newLike);
            }
        }
 private Task <int> AddMovieLikeFake()
 {
     return(Task.Run(() =>
     {
         var movieLike = new MovieLike()
         {
             MovieId = 1,
             UserId = 1,
             CreatedDate = DateTime.Now
         };
         return movieLike.MovieId;
     }));
 }
예제 #6
0
        public ActionResult <MovieLike> PostMovieLike(MovieLike oMovieLike)
        {
            // Adds or removes (if already exists) a Like for a specific Movie
            int iMovieLikeID = oMovieLikeRepository.AddMovieLike(oMovieLike.MovieID,
                                                                 int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value));

            if (iMovieLikeID == 0)
            {
                return(NoContent());
            }
            else
            {
                return(CreatedAtAction("GetMovieLike", new { id = iMovieLikeID }, oMovieLike));
            }
        }
        public async Task <int> Handle(AddMovieLikeCommand request, CancellationToken cancellationToken)
        {
            var entity = new MovieLike
            {
                MovieId     = request.MovieId,
                CreatedDate = DateTime.Now,
                UserId      = request.UserId
            };

            _context.MovieLikes.Add(entity);

            await _context.SaveChangesAsync(cancellationToken);

            return(entity.MovieId);
        }
예제 #8
0
        public void AddDislike(int movieId, int userId)
        {
            MovieLike movieDisLike = MovieLikeRepository.GetByForeignKey(movieId, userId);

            if (movieDisLike == null)
            {
                MovieLike newMovieDisLike = CreateNewMovieDisLike(movieId, userId);
                MovieLikeRepository.Add(newMovieDisLike);
            }
            else
            {
                movieDisLike.Status = false;
                MovieLikeRepository.Update(movieDisLike);
            }
        }
예제 #9
0
        public async Task LikeMovie(string userID, ObjectId movieID)
        {
            System.Diagnostics.Debug.WriteLine(movieID);
            UserInformation user = await GetUserInformation(userID);

            MovieLike newMovieLike = new MovieLike();

            Movie movie = await GetMovie(movieID);

            newMovieLike.Id   = movie.ID;
            newMovieLike.Name = movie.Title;
            user.MovieLikes.Add(newMovieLike);

            var update = Builders <UserInformation> .Update.Set(x => x.MovieLikes, user.MovieLikes);

            await Users.UpdateOneAsync(x => x.Id == userID, update);
        }
예제 #10
0
        public IActionResult PutMovieLike(int id, MovieLike oMovieLike)
        {
            if (id != oMovieLike.MovieLikeID)
            {
                return(BadRequest());
            }

            try
            {
                var oExistingMovieLike = oMovieLikeRepository.GetById(id);
                oExistingMovieLike.MovieID = oMovieLike.MovieID;
                oExistingMovieLike.UserID  = oMovieLike.UserID;

                oMovieLikeRepository.Update(oExistingMovieLike);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(NoContent());
        }
예제 #11
0
        public async Task <ActionResult <MovieLike> > PostMovieLike(MovieLike movieLike)
        {
            movieLike.Date = DateTime.Now;
            _context.MovieLikes.Add(movieLike);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MovieLikeExists(movieLike.AccountId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(movieLike);
        }
예제 #12
0
 public List <UserInformation> GetAllUsersWithExceptCurrent(string ID, MovieLike movie)
 {
     return(Users.Find(x => x.Id != ID && x.MovieLikes.Contains(movie)).ToListAsync().Result);
 }
예제 #13
0
        public void Remove(int movieId, int userId)
        {
            MovieLike movieLike = MovieLikeRepository.GetByForeignKey(movieId, userId);

            MovieLikeRepository.Remove(movieLike);
        }
예제 #14
0
 public void Remove(MovieLike movieLike)
 {
     Context.MovieLikes.Remove(movieLike);
     Context.SaveChanges();
 }
예제 #15
0
 public void Update(MovieLike movieLike)
 {
     Context.MovieLikes.Update(movieLike);
     Context.SaveChanges();
 }
예제 #16
0
 public void Add(MovieLike movieLike)
 {
     Context.MovieLikes.Add(movieLike);
     Context.SaveChanges();
 }