Пример #1
0
        public HttpResponseMessage Delete(int id)
        {
            try
            {
                var livro = _livroService.BuscarLivro(id);

                if (livro.Id == 0)
                {
                    JsonResult.Status  = false;
                    JsonResult.Message = "404 Not Found";
                    return(Request.CreateResponse(HttpStatusCode.NotFound, JsonResult));
                }


                _livroService.ExcluirLivro(id);

                JsonResult.Status  = true;
                JsonResult.Object  = null;
                JsonResult.Message = "Excluido com sucesso";
                return(Request.CreateResponse(HttpStatusCode.OK, JsonResult));
            }
            catch (Exception ex)
            {
                JsonResult.Status  = false;
                JsonResult.Message = ex.Message;
                return(Request.CreateResponse(HttpStatusCode.BadRequest, JsonResult));
            }
        }
        public async Task <ActionResult <dynamic> > Excluir(decimal id)
        {
            try
            {
                var result = _livroService.ExcluirLivro(id);

                return(await Task.FromResult(result.Result));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }