public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Login,Password,adm")] Usuario usuario) { if (HttpContext.Session.GetString("login") == null || HttpContext.Session.GetString("login") == "") { return(RedirectToAction("Login", "Home")); } ViewData["usuario"] = HttpContext.Session.GetString("name"); ViewData["isAdm"] = HttpContext.Session.GetString("is_adm"); if (id != usuario.Id) { return(NotFound()); } if (ModelState.IsValid) { try { Usuario user = new Usuario { Nome = usuario.Nome, Login = usuario.Login, Password = EncryptHash.Encript(usuario.Password), adm = usuario.adm }; _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(usuario.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(usuario)); }
public async Task <IActionResult> Edit(Pesquisa pesquisa) { if (pesquisa.id != pesquisa.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pesquisa); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(Redirect("https://www.google.com.br")); } return(View(pesquisa)); }
public IActionResult Edit(Cliente cliente) { if (HttpContext.Session.GetString("login") == null || HttpContext.Session.GetString("login") == "") { return(RedirectToAction("Login", "Home")); } ViewData["usuario"] = HttpContext.Session.GetString("name"); ViewData["isAdm"] = HttpContext.Session.GetString("is_adm"); if (!ModelState.IsValid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cliente); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ClienteExists(cliente.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cliente)); }