public bool EditCategory(Category category) { using (var uow = new UnitOfWork()) { uow.CategoryRepository.Update(category); return uow.Save() > 0; } }
public bool CreateCategory(Category category) { using (var uow = new UnitOfWork()) { uow.CategoryRepository.Insert(category); return uow.Save() == 1; } }
public IHttpActionResult Post(CategoryVM request) { if (request.Name.IsNullOrEmpty()) { return this.BadRequest("Category name must be supplied."); } Category category = new Category { Name = request.Name }; if (this.categoryService.CreateCategory(category)) { List<CategoryVM> categories = GetCategories(); return this.Created(categories); } return this.BadRequest(); }