public void UpdateReview(Domain.Model.Review inputReview) { _logger.LogInformation($"Updating review with ID {inputReview.Id}"); Context.Review currentEntity = _dbContext.Reviews.Find(inputReview.Id); Context.Review newEntity = Mapper.UnMapReview(inputReview); _dbContext.Entry(currentEntity).CurrentValues.SetValues(newEntity); }
public Domain.Model.Review GetReviewById(int reviewId) { _logger.LogInformation($"Retrieving review id: {reviewId}"); Context.Review returnReview = _dbContext.Reviews .Include(p => p.Person) .Include(p => p.Seller) .First(p => p.ReviewId == reviewId); return(Mapper.MapReview(returnReview)); }
public void AddReview(Domain.Model.Review inputReview) { if (inputReview.Id != 0) { _logger.LogWarning($"Review to be added has an ID ({inputReview.Id}) already: ignoring."); } _logger.LogInformation("Adding review"); Context.Review entity = Mapper.UnMapReview(inputReview); entity.ReviewId = 0; _dbContext.Add(entity); }
public void DeleteReviewById(int reviewId) { _logger.LogInformation($"Deleting review with ID {reviewId}"); Context.Review entity = _dbContext.Reviews.Find(reviewId); _dbContext.Remove(entity); }