Example #1
0
        public async Task <ICommonDto> RemoveCategories(string id, CategoriesBindingModel model)
        {
            await MovieExists(id);

            var updateBuilder = Builders <Domain.Entity.Movie> .Update.PullAll(x => x.Categories, model.Categories);

            return(await ProcessUpdateArrayElements(id, updateBuilder));
        }
Example #2
0
        public IHttpActionResult EditCategoryName(int id, [FromBody] CategoriesBindingModel categ)
        {
            if (!this._context.Categories.Any(c => c.Name == categ.Name))
            {
                var category = this._context.Categories.FirstOrDefault(c => c.Id == id);

                category.Name = categ.Name;

                this._context.SaveChanges();

                return(this.Ok("Name changed!"));
            }

            return(this.BadRequest("Category with that name already exists!"));
        }
Example #3
0
        public IHttpActionResult AddCategory([FromBody] CategoriesBindingModel categ)
        {
            if (this._context.Categories.Any(c => c.Name == categ.Name))
            {
                return(this.BadRequest("Category with that name already exists!"));
            }

            this._context.Categories.Add(new Category
            {
                Name = categ.Name
            });

            this._context.SaveChanges();

            return(this.Ok("Category successfully added!"));
        }
Example #4
0
 public async Task <IHttpActionResult> RemoveCategories(string id, CategoriesBindingModel model)
 => Ok(await _movieService.RemoveCategories(id, model));