public static MovieLikeModel ToMovieLikeModel(this MovieLike movieLike) { return(new MovieLikeModel() { Id = movieLike.Id, UserId = movieLike.UserId, MovieId = movieLike.MovieId }); }
private static MovieLikeModel ConvertToMovieLikeModel(MovieLike x) { return(new MovieLikeModel { Id = x.Id, RecipeId = x.MovieId, UserId = x.UserId, Status = x.Status, }); }
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); }
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; })); }
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); }
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); } }
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); }
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()); }
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); }
public List <UserInformation> GetAllUsersWithExceptCurrent(string ID, MovieLike movie) { return(Users.Find(x => x.Id != ID && x.MovieLikes.Contains(movie)).ToListAsync().Result); }
public void Remove(int movieId, int userId) { MovieLike movieLike = MovieLikeRepository.GetByForeignKey(movieId, userId); MovieLikeRepository.Remove(movieLike); }
public void Remove(MovieLike movieLike) { Context.MovieLikes.Remove(movieLike); Context.SaveChanges(); }
public void Update(MovieLike movieLike) { Context.MovieLikes.Update(movieLike); Context.SaveChanges(); }
public void Add(MovieLike movieLike) { Context.MovieLikes.Add(movieLike); Context.SaveChanges(); }