public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Sobrenome,DataDeNascimento,Telefone,RG,CPF")] Cliente cliente)
        {
            if (id != cliente.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cliente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClienteExists(cliente.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Numero,DataCompra,TotalCompra,EstadoAtual")] Venda venda)
        {
            if (id != venda.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(venda);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VendaExists(venda.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(venda));
        }
        public async Task <IActionResult> Create([Bind("Id,Nome,Sobrenome,DataDeNascimento,CPF,RG,Email,Telefone,Celular")] Funcionario funcionario)
        {
            if (ModelState.IsValid)
            {
                _context.Add(funcionario);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(funcionario));
        }
        public async Task <IActionResult> Create(Produto produto, IFormFile Imagem)
        {
            if (ModelState.IsValid)
            {
                if (Imagem.Length > 0)
                {
                    using (var stream = new MemoryStream())
                    {
                        await Imagem.CopyToAsync(stream);

                        produto.Imagem = stream.ToArray();
                    }
                }
                produto.DataEntrada = DateTime.Now;
                _context.Add(produto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(produto));
        }