示例#1
0
 public HttpResponseMessage Delete(Int64 id)
 {
     try
     {
         _patrimonioRepository.DeletePatrimonio(id);
         return(Request.CreateResponse(HttpStatusCode.OK, "Patrimonio exclída com sucesso", "application/json"));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message, "application/json"));
     }
 }
示例#2
0
        public IActionResult DeletePatrimonio(int id)
        {
            if (!_patrepo.PatrimonioExists(id))
            {
                return(NotFound());
            }

            var patrimoniosDto = _patrepo.GetPatrimonio(id);

            if (!_patrepo.DeletePatrimonio(patrimoniosDto))
            {
                ModelState.AddModelError("", $"Algo errado ao deletar {patrimoniosDto.Nome}");
                return(StatusCode(500, ModelState));
            }

            return(NoContent());
        }