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)); }
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!")); }
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!")); }
public async Task <IHttpActionResult> RemoveCategories(string id, CategoriesBindingModel model) => Ok(await _movieService.RemoveCategories(id, model));