public async Task RemoveFavorite(FavoriteRequestModel favoriteRequest) { var favorite = await _favoriteRepository.ListAsync(f => f.MovieId == favoriteRequest.MovieId && f.UserId == favoriteRequest.UserId); await _favoriteRepository.DeleteAsync(favorite.First()); }
public async Task <bool> RemoveFavoriteMovie(int movieId, int userId) { var favorites = await _favoriteRepository.ListAsync(f => f.MovieId == movieId && f.UserId == userId); var result = await _favoriteRepository.DeleteAsync(favorites.FirstOrDefault()); return(result > 0); }
public async Task <bool> UnFavoriteMovie(int id, int movieId) { //find favorite movie by two id var favorite = await _favoriteRepository.ListAsync(f => f.UserId == id && f.MovieId == movieId); var result = await _favoriteRepository.DeleteAsync(favorite.First()); return(result > 0); }
public async Task RemoveFavorite(FavoriteRequestModel favoriteRequest) { if (_currentUserService.UserId != favoriteRequest.UserId) { throw new HttpException(HttpStatusCode.Unauthorized, "You are not authorized to delete the favorites."); } if (!await FavoriteExists(favoriteRequest.UserId, favoriteRequest.MovieId)) { throw new ConflictException("Favorite does not exist."); } var dbFavorite = await _favoriteRepository.ListAsync(f => f.UserId == favoriteRequest.UserId && f.MovieId == favoriteRequest.MovieId); //var favorite = _mapper.Map<Favorite>(favoriteRequest); await _favoriteRepository.DeleteAsync(dbFavorite.First()); }