public ActionResult <CategoryDto> AddCategory(CategoryDto category) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Category newCategory = new Category(); category.CopyValuesTo(newCategory); _unitOfWork.CategoryRepository.Insert(newCategory); _unitOfWork.Save(); return(CreatedAtAction(nameof(GetCategory), new { id = newCategory.Id }, new CategoryDto(newCategory))); }