public void Delete(long id) { Models.AdminComment comment = this._db.AdminComments.Where(c => c.adminCommentId == id).SingleOrDefault(); this._db.AdminComments.Attach(comment); this._db.Entry(comment).State = System.Data.Entity.EntityState.Deleted; this._db.SaveChanges(); }
public void Post([FromBody] Models.AdminComment comment) { if (comment.adminCommentId == 0) { this._db.AdminComments.Add(comment); } else { this._db.AdminComments.Attach(comment); this._db.Entry(comment).State = System.Data.Entity.EntityState.Modified; } this._db.SaveChanges(); }