public ActionResult Create(People user) { if (ModelState.IsValid) { context.People.Add(user); context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Edit(int id, People user) { People _user = context.People.Single(p => p.UserID == id); if (ModelState.IsValid) { _user.Username = user.Username; _user.Password = user.Password; context.SaveChanges(); return RedirectToAction("Index"); } return View(user); }
public ActionResult Register(RegisterViewModel registerUser) { if (ModelState.IsValid) { var sha1 = new SHA1CryptoServiceProvider(); People user = new People() { Username = registerUser.Username, Password = Convert.ToBase64String(sha1.ComputeHash(Encoding.Unicode.GetBytes(registerUser.Password))), Email = registerUser.Email }; context.People.Add(user); context.SaveChanges(); return RedirectToAction("Index", "Private"); } return View(); }
public ActionResult Delete(int id, People user) { People _user = context.People.Single(p => p.UserID == id); context.People.Remove(_user); context.SaveChanges(); return RedirectToAction("Index"); }