Exemplo n.º 1
0
        public async Task <ActionResult> Post([FromBody] CategoryAddDto categoryAdd)
        {
            Category categ = await _categoryBusiness.AddCategory(categoryAdd);

            if (categ != null)
            {
                return(new CreatedAtRouteResult("GetCategory", new { id = categ.CategoryId }, categ));
            }
            else
            {
                return(new StatusCodeResult(500));
            }
        }
Exemplo n.º 2
0
        public IActionResult Post(string values)
        {
            var model      = new Category();
            var valuesDict = JsonConvert.DeserializeObject <IDictionary>(values);

            PopulateModel(model, valuesDict);

            if (!TryValidateModel(model))
            {
                return(BadRequest(ModelState.GetFullErrorMessage()));
            }

            _categoryBusiness.AddCategory(model);

            return(Json(model.Id));
        }
Exemplo n.º 3
0
 public void AddCategory(Category category)
 {
     _categoryBusiness.AddCategory(category);
 }