コード例 #1
0
        public async Task <IActionResult> Create([Bind("Nome,Celular,email,ValorMeta")] Vendedores vendedor)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(vendedor);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError(ex.Message, "Falha ao inserir registro");
            }
            return(View(vendedor));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Nome,Endereco,Cidade,Uf,Cep,Celular,email")] Clientes cliente)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(cliente);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException ex)
            {
                ModelState.AddModelError(ex.Message, "Falha ao inserir registro");
            }
            return(View(cliente));
        }