public async Task <IActionResult> PostAsync([FromBody] EstabelecimentoUser item) { if (item == null) { return(BadRequest(new { status = 400, message = "Objeto inválido." })); } if (ModelState.IsValid) { var response = await _estabelecimentoRepository.AddAsync(MapperEstabelecimento(item)); if (response.Equals("success")) { return(Ok(new { status = HttpContext.Response.StatusCode, message = "Cadastrado com sucesso.", data = item })); } return(BadRequest(new { status = 400, message = response })); } else { return(BadRequest(new { status = 400, message = ModelState.Values.SelectMany(m => m.Errors) .Select(e => e.ErrorMessage) .ToList() })); } }