예제 #1
0
 public void DeleteUserLikedJoke(int userId, int jokeId)
 {
     using (var ctx = new JokesContext(_connectionString))
     {
         ctx.Database.ExecuteSqlInterpolated($"DELETE FROM UserLikedJokes WHERE UserId = {userId} AND JokeId = {jokeId}");
         ctx.SaveChanges();
     }
 }
예제 #2
0
 public void LikeDislikeJoke(UserLikedJoke ulj)
 {
     using (var ctx = new JokesContext(_connectionString))
     {
         ctx.UserLikedJokes.Add(ulj);
         ctx.SaveChanges();
     }
 }
예제 #3
0
        public void AddUser(User user, string password)
        {
            user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(password);

            using (var ctx = new JokesContext(_connectionString))
            {
                ctx.Users.Add(user);
                ctx.SaveChanges();
            }
        }
예제 #4
0
 public void AddJoke(JokeResult jr)
 {
     using (var ctx = new JokesContext(_connectionString))
     {
         ctx.Jokes.Add(new Joke
         {
             Number    = jr.Number,
             Setup     = jr.Setup,
             Punchline = jr.Punchline
         });
         ctx.SaveChanges();
     }
 }