コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,Login,Senha")] Usuario usuario)
        {
            if (id != usuario.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usuario);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsuarioExists(usuario.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(usuario));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DdOrigem,DdDestino,Valor")] Tarifa tarifa)
        {
            if (id != tarifa.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tarifa);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TarifaExists(tarifa.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tarifa));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Descricao,Porcentagem,Criado,Editado")] Plano plano)
        {
            if (id != plano.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plano);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlanoExists(plano.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(plano));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Descricao,Minutos,Tipo")] Pacote pacote)
        {
            if (id != pacote.Id)
            {
                return(NotFound());
            }


            var planoPacote = await _context.Pacote.AsNoTracking()
                              .Include(pac => pac.Plano)
                              .FirstOrDefaultAsync(pac => pac.Id == id);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pacote);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PacoteExists(pacote.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }


                return(RedirectToAction("Details", "Planos", new { @id = planoPacote.Plano.Id }));
                // return RedirectToAction(nameof(Index));
            }
            return(View(pacote));
        }