예제 #1
0
        public IActionResult Delete(int id)
        {
            try
            {
                var produto = business.ConsultarPorId(id);

                if (produto != null)
                {
                    business.Excluir(id);
                    return(Ok($"Produto {produto.Nome}, Excluído com sucesso"));
                }
                else
                {
                    return(BadRequest("Produto não encontrado"));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
예제 #2
0
        public async Task <IActionResult> GetById([FromRoute] string id)
        {
            try
            {
                var clientes = await _produtoBusiness.ConsultarPorId(int.Parse(id)).ConfigureAwait(false);

                if (clientes == null)
                {
                    return(NoContent());
                }

                return(Ok(clientes));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex }));
            }
        }