public IHttpActionResult Delete(NoteCategoriesEdit model)
        {
            var service = CategoriesService();

            if (!service.DeleteCategoriesFromNote(model))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 2
0
        //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);
            }
        }