Ejemplo n.º 1
0
        public Category CreateCategory(RequestCreateCategory model)
        {
            var entity = model.ToEntity();

            PrepareCreate(entity);
            return(Add(entity));
        }
Ejemplo n.º 2
0
        public IActionResult CreateCategory([FromBody] RequestCreateCategory _category)
        {
            Category entity;

            if (ModelState.IsValid)
            {
                entity = _categoryServices.CreateCategory(_category);
                _categoryServices.Commit();
                return(Created($"api/categories/{entity.Id}", _category));
            }
            else
            {
                return(BadRequest());
            }
        }