Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Data,UsuarioId,QtdeItens,ValorTotal")] Pedido pedido)
        {
            if (id != pedido.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pedido);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PedidoExists(pedido.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UsuarioId"] = new SelectList(_context.Usuarios, "Id", "Id", pedido.UsuarioId);
            return(View(pedido));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("Id,PrecoUnitario,Nome")] Produto produto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(produto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(produto));
        }
        public async Task <IActionResult> Create([Bind("Id,Nome,Nascimento,Altura")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Id,PedidoId,Quantidade,ProdutoId")] Itens itens)
        {
            if (ModelState.IsValid)
            {
                _context.Add(itens);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PedidoId"]  = new SelectList(_context.Pedidos, "Id", "Id", itens.PedidoId);
            ViewData["ProdutoId"] = new SelectList(_context.Produtos, "Id", "Id", itens.ProdutoId);
            return(View(itens));
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("Id,Nome,Cpf,Email")] Usuario usuario)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(usuario);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(usuario));
        }