Esempio n. 1
0
        public async Task <IActionResult> Crear([FromBody] CategoriaModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await _service.Crear(CategoriaConvert.toEntity(model));

                    if (result != null)
                    {
                        return(Ok(CategoriaConvert.toModel(result)));
                    }
                    else
                    {
                        return(BadRequest("Error creando la Categoria!!"));
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));

                throw e;
            }
        }