コード例 #1
0
        public async Task <IActionResult> AddCategory([FromBody] CategoriesDTO categoriesDTO)
        {
            try
            {
                var category = _mapper.Map <Categoria>(categoriesDTO);
                var resp     = await _categoryServices.AddCategory(category);

                if (resp == null)
                {
                    return(StatusCode(StatusCodes.Status404NotFound, resp));
                }
                return(StatusCode(StatusCodes.Status201Created, category));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }