public IHttpActionResult Delete(NoteCategoriesEdit model) { var service = CategoriesService(); if (!service.DeleteCategoriesFromNote(model)) { return(InternalServerError()); } return(Ok()); }
//Delete categories from a note public bool DeleteCategoriesFromNote(NoteCategoriesEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .NoteCategories .Single(e => e.NoteID == model.NoteID && e.CategoryID == model.CategoryID); ctx.NoteCategories.Remove(entity); return(ctx.SaveChanges() == 1); } }