Пример #1
0
        public async Task <ActionResult <Data.Models.ProductCategory> > PostCategory(Data.Models.ProductCategory category)
        {
            if (category == null)
            {
                return(BadRequest());
            }

            category.Slug = Slug.Generate(category.Title);

            await _categoryService.Create(category);

            return(CreatedAtAction("GetCategory", new { id = category.Id }, category));
        }
Пример #2
0
        public async Task <IActionResult> PutProductCategory(int id, Data.Models.ProductCategory category)
        {
            if (id != category.Id || category == null)
            {
                return(BadRequest());
            }

            var _categoryExists = await _categoryService.GetById(id);

            if (_categoryExists == null)
            {
                return(NotFound());
            }

            await _categoryService.Edit(category);

            return(NoContent());
        }