public async Task <IActionResult> Create([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 (ModelState.IsValid) { Usuario user = new Usuario { Nome = usuario.Nome, Login = usuario.Login, Password = EncryptHash.Encript(usuario.Password), adm = usuario.adm }; _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(usuario)); }
public async Task <IActionResult> DeleteConfirmed(int id) { 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"); var cliente = await _context.Cliente.FindAsync(id); _context.Cliente.Remove(cliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
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)); }