Example #1
0
 public void Put(Post post)
 {
     if (ModelState.IsValid)
     {
         using (var db = new AngularJSBlogContext())
         {
             db.Entry <Post>(post).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
         }
     }
 }
Example #2
0
 public void Post(Post post)
 {
     if (ModelState.IsValid)
     {
         using (var db = new AngularJSBlogContext())
         {
             db.Posts.Add(post);
             db.SaveChanges();
         }
     }
 }
Example #3
0
 public void Delete(int id)
 {
     using (var db = new AngularJSBlogContext())
     {
         var post = db.Posts.FirstOrDefault(p => p.Id == id);
         if (post != null)
         {
             db.Posts.Remove(post);
             db.SaveChanges();
         }
     }
 }