Beispiel #1
0
 public void LikeJoke(Joke joke, int userId, bool liked)
 {
     using (var cxt = new JokeContext(_connectionString))
     {
         var ulj = new UserLikedJokes();
         ulj.JokeId    = joke.Id;
         ulj.UserId    = userId;
         ulj.Liked     = liked;
         ulj.DateLiked = DateTime.Now;
         cxt.UserLikedJokes.Add(ulj);
         if (!cxt.Jokes.Contains(joke))
         {
             cxt.Jokes.Add(joke);
         }
         cxt.SaveChanges();
     }
 }