Пример #1
0
        public bool AddCategoriesToNote(NoteCategoriesCreate model)
        {
            var entity =
                new NoteCategories()
            {
                NoteID     = model.NoteID,
                CategoryID = model.CategoryID,
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.NoteCategories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public IHttpActionResult Post(NoteCategoriesCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CategoriesService();

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

            return(Ok());
        }