public async Task <IActionResult> Edit(int id, [Bind("AId,Username,Password,Email")] Admin admin) { if (HttpContext.Session.GetInt32("AId") < 0) { return(RedirectToAction("Login", "Admins")); } if (id != admin.AId) { return(RedirectToAction(nameof(Index)));//asdf; } if (ModelState.IsValid) { try { admin.Password = GetMd5Hash(MD5.Create(), "xfo3ip2a51s23d15g5j" + admin.Password + "$4Lt"); _context.Update(admin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminExists(admin.AId)) { return(RedirectToAction(nameof(Index)));//asdf; } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(admin)); }
public async Task <IActionResult> Edit(int id, [Bind("UId,FName,LName,Email,Gender")] Users users) { if (HttpContext.Session.GetInt32("AId") < 0) { return(RedirectToAction("Login", "Admins")); } if (id != users.UId) { return(RedirectToAction(nameof(Index)));//asdf } if (ModelState.IsValid) { try { _context.Update(users); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(users.UId)) { return(RedirectToAction(nameof(Index)));//asdf } else { throw; } } //return RedirectToAction(nameof(Index));//asdf return(RedirectToAction("Details", "Users", new { id = users.UId })); } return(View(users)); }
public async Task <IActionResult> Edit(int id, [Bind("RelId,FName,LName,Relation,UId")] Relative relative) { if (HttpContext.Session.GetInt32("AId") < 0) { return(RedirectToAction("Login", "Admins")); } if (id != relative.RelId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(relative); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RelativeExists(relative.RelId)) { return(NotFound()); } else { throw; } } //return RedirectToAction(nameof(Index)); return(RedirectToAction("Details", "Users", new { id = relative.UId })); } ViewData["UId"] = new SelectList(_context.Users, "UId", "UId", relative.UId); return(View(relative)); }