public async Task <MemeRating> FetchRating(MemeReaction reaction) { var rating = await _context.MemeRatings .FirstOrDefaultAsync(r => r.MemeId == reaction.MemeId && r.UserId == reaction.UserId); if (rating == null) { rating = new MemeRating() { UserId = reaction.UserId, MemeId = reaction.MemeId, }; await _context.MemeRatings.AddAsync(rating); } return(rating); }
public void DeleteRating([NotNull] MemeRating rating) { _context.MemeRatings.Remove(rating); }