public IActionResult Create([Bind] Estabelecimento estabelecimento) { if (ModelState.IsValid) { _contextDAO.Add(estabelecimento); return(RedirectToAction("Index")); } return(View(estabelecimento)); }
public void CreateEstabelecimento(Estabelecimento estabelecimento) { if (!ValidationHelper.ValidaCNPJ(estabelecimento.CNPJ)) { throw new ArgumentException("CNPJ inválido."); } estabelecimentoRepository.Add(estabelecimento); this.SaveEstabelecimento(); }
public IActionResult Create([FromBody] Estabelecimento estabelecimento) { if (estabelecimento == null) { return(BadRequest()); } if (_estabelecimentoRepository.Add(estabelecimento)) { return(CreatedAtRoute("GetEstabelecimento", new { id = estabelecimento.Id }, estabelecimento)); } else { return(BadRequest()); } }
public IActionResult Create([FromBody] Estabelecimento estabelecimento) { try { if (estabelecimento == null || !ModelState.IsValid) { return(BadRequest("Invalid State")); } _estabelecimentoRepository.Add(estabelecimento); } catch (Exception) { return(BadRequest("Error while creating")); } return(Ok(estabelecimento)); }