Exemplo n.º 1
0
 public async Task <IActionResult> Edit(long?id, [Bind("UsuarioId, Nome, DataNascimento, CPF")] Usuarios usuarios)
 {
     if (id != usuarios.UsuarioId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(usuarios);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!UsuariosExists(usuarios.UsuarioId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(usuarios));
 }
 public async Task <IActionResult> Edit(long?id, [Bind("AmbienteId, Nome, AparelhoId")] Ambientes ambientes)
 {
     if (id != ambientes.AmbienteId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(ambientes);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!AmbientesExists(ambientes.AmbienteId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     ViewBag.Aparelho = new SelectList(_context.Aparelho.OrderBy(a => a.Nome), "AparelhoId", "Nome", ambientes.AparelhoId);
     return(View(ambientes));
 }
Exemplo n.º 3
0
 public async Task <IActionResult> Edit(long?id, [Bind("AparelhoId, Nome, Modelo, Tipo")] Aparelhos aparelhos)
 {
     if (id != aparelhos.AparelhoId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(aparelhos);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!AparelhosExists(aparelhos.AparelhoId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(aparelhos));
 }
 public async Task <IActionResult> Edit(long?id, [Bind("ResidenciaId, Cidade, Bairro, CEP, AmbienteId")] Residencias residencias)
 {
     if (id != residencias.ResidenciaId)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(residencias);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!ResisdenciasExists(residencias.ResidenciaId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     ViewBag.Ambiente = new SelectList(_context.Ambiente.OrderBy(a => a.Nome), "AmbienteId", "Nome", residencias.AmbienteId);
     return(View(residencias));
 }
Exemplo n.º 5
0
        public async Task UpdateAsync(Regiao regiao)
        {
            var hasAny = await _context.Regiao.AnyAsync(s => s.Id == regiao.Id);

            if (!hasAny)
            {
                throw new NotFoundException("Id not found");
            }

            try
            {
                _context.Update(regiao);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }