コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,data,aprovado,responsavel")] AnaliseQualidade analiseQualidade, IFormCollection collection)
        {
            int idOrdem = Convert.ToInt16(collection["Ordem"]);

            if (id != analiseQualidade.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var ord = await _context.Ordem.FindAsync(idOrdem);

                    analiseQualidade.ordem = ord;

                    _context.Update(analiseQualidade);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnaliseQualidadeExists(analiseQualidade.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(analiseQualidade));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,nome")] Produto produto)
        {
            if (id != produto.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(produto);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProdutoExists(produto.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(produto));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,nome,telefone,endereco")] 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));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,data,hora,qdte")] Ordem ordem, IFormCollection collection)
        {
            if (id != ordem.ID)
            {
                return(NotFound());
            }
            int idProduto = Convert.ToInt16(collection["Produto"]);
            int idCliente = Convert.ToInt16(collection["Cliente"]);

            if (ModelState.IsValid)
            {
                try
                {
                    var prod = await _context.Produto.FindAsync(idProduto);

                    ordem.produto = prod;
                    var cli = await _context.Cliente.FindAsync(idCliente);

                    ordem.cliente = cli;


                    _context.Update(ordem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrdemExists(ordem.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ordem));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,nome,tamanho,qtde")] Embalagem embalagem, IFormCollection collection)
        {
            if (id != embalagem.ID)
            {
                return(NotFound());
            }
            int idProduto    = Convert.ToInt16(collection["Produto"]);
            int idFornecedor = Convert.ToInt16(collection["Fornecedor"]);

            if (ModelState.IsValid)
            {
                try
                {
                    var prod = await _context.Produto.FindAsync(idProduto);

                    embalagem.produto = prod;
                    var forn = await _context.Fornecedor.FindAsync(idFornecedor);

                    embalagem.fornecedor = forn;

                    _context.Update(embalagem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmbalagemExists(embalagem.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(embalagem));
        }