예제 #1
0
        public static void DeleteJoke(JokeDbContext _db, int jokeId)
        {
            Joke j = _db.Jokes.Find(jokeId); // find joke and start tracking

            _db.Jokes.Remove(j);             // marks joke as deleted
            _db.SaveChanges();               // saves to database
        }
예제 #2
0
        public static void UpdateJoke(JokeDbContext _db, int JokeId, string jokeText, string jokeCategory)
        {
            Joke j = _db.Jokes.Find(JokeId);

            _db.Jokes.Attach(j).State = EntityState.Modified;
            j.JokeText = jokeText;
            j.Category = jokeCategory;
            _db.SaveChanges();
        }
예제 #3
0
 public static void addJoke(JokeDbContext _db, Joke newData)
 {
     _db.Jokes.Add(newData);
     _db.SaveChanges();
 }