public async Task <string> CreateAsync(CategoryRequastModel model) { var category = new Category { Name = model.Name, ParentCategoryName = model.ParentCategoryName, ShowInFilter = model.ShowInFilter }; await Data.AddAsync(category).ConfigureAwait(false); await Data.SaveChangesAsync().ConfigureAwait(false); return(category.Id.ToString()); }
public async Task <Result> UpdateAsync(Guid id, CategoryRequastModel model) { var category = await FindById(id) .ConfigureAwait(false); if (category == null) { return(NotFound); } category.Name = model.Name; category.ParentCategoryName = model.ParentCategoryName; category.ShowInFilter = model.ShowInFilter; await Data.SaveChangesAsync() .ConfigureAwait(false); return(Result.Success); }
public async Task <ActionResult> Update(Guid id, CategoryRequastModel model) { return(await _categories .UpdateAsync(id, model) .ToActionResult()); }
public async Task <string> Create(CategoryRequastModel model) { return(await _categories .CreateAsync(model)); }