public async Task <IHttpActionResult> Add([FromBody] Ato_NormativoModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } object result = await repository.Add(rhNetContext, model); if (result.GetType() == typeof(Ato_NormativoModel)) { return(Ok(result)); } else { return(BadRequest(result.ToString())); } }
public async Task <ActionResult> Add([FromServices] RhNetContext rhNetContext, [FromBody] Ato_NormativoModel ato_normativoModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Ato_NormativoRepository repository = new Ato_NormativoRepository(); object result = await repository.Add(rhNetContext, ato_normativoModel); if (result.GetType() == typeof(Ato_NormativoModel)) { return(Ok(result)); } else { ModelState.AddModelError("errors", result.ToString()); return(BadRequest(ModelState)); } }