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(); } }
public void LikeDislikeJoke(UserLikedJoke ulj) { using (var ctx = new JokesContext(_connectionString)) { ctx.UserLikedJokes.Add(ulj); ctx.SaveChanges(); } }
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(); } }
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(); } }