Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public void DeleteRating([NotNull] MemeRating rating)
 {
     _context.MemeRatings.Remove(rating);
 }