//[ValidateAntiForgeryToken] public IActionResult Create([FromBody] Starships entity) { try { if (ModelState.IsValid) { if (entity.Id == 0) { service.Create(entity); Response.StatusCode = 201;//Created return(Ok(new { msg = "criado com sucesso!" })); } else { Response.StatusCode = 404;// Not Acceptable return(null); } } else { Response.StatusCode = 406;// Not Acceptabl return(new ObjectResult("deu ruim! ")); } } catch (Exception e) { Response.StatusCode = 406;// Not Acceptable return(new ObjectResult("deu ruim! Mensagem: " + e.Message)); } }
//[ValidateAntiForgeryToken] public IActionResult Create([FromBody] Planets entity) { if (ModelState.IsValid) { if (entity.Id == 0) { service.Create(entity); Response.StatusCode = 201;//Created return(Ok(new { msg = "criado com sucesso!" })); } else { Response.StatusCode = 404;// Not Acceptable return(null); } } else { Response.StatusCode = 406;// Not Acceptable return(new ObjectResult("deu ruim!")); } }