コード例 #1
0
 public bool EditCategory(Category category)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CategoryRepository.Update(category);
         return uow.Save() > 0;
     }
 }
コード例 #2
0
 public bool CreateCategory(Category category)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CategoryRepository.Insert(category);
         return uow.Save() == 1;
     }
 }
コード例 #3
0
        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();
        }