Exemplo n.º 1
0
 public IActionResult Create([Bind] Estabelecimento estabelecimento)
 {
     if (ModelState.IsValid)
     {
         _contextDAO.Add(estabelecimento);
         return(RedirectToAction("Index"));
     }
     return(View(estabelecimento));
 }
Exemplo n.º 2
0
        public void CreateEstabelecimento(Estabelecimento estabelecimento)
        {
            if (!ValidationHelper.ValidaCNPJ(estabelecimento.CNPJ))
            {
                throw new ArgumentException("CNPJ inválido.");
            }

            estabelecimentoRepository.Add(estabelecimento);
            this.SaveEstabelecimento();
        }
Exemplo n.º 3
0
        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));
        }