Exemple #1
0
        public IActionResult Deletar(int Id)
        {
            JsonResult rs = null;

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                rs             = new JsonResult(dao.Deletar(Id));
                rs.ContentType = "application/json";

                if (!Convert.ToBoolean(rs.Value))
                {
                    rs.StatusCode = 204;
                    rs.Value      = "Ocorreu um erro.";
                }
                else
                {
                    rs.StatusCode = 200;
                }
            }
            catch (SystemException ex)
            {
                rs            = new JsonResult("");
                rs.StatusCode = 404;
                rs.Value      = ex.Message;
            }

            return(Json(rs));
        }