public ActionResult Edit(int id, FormCollection collection) { if (Session["User"] == null) { return(RedirectToAction("Login", "Pages")); } try { BL.User user = BL.User.getById(id); user.Username = collection["Username"]; // If a password has been specified, let's update the user's old password if (collection["Password"] != "") { user.Password = Settings.SecureString(collection["Password"]); } user.save(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection collection) { if (Session["User"] == null) { return(RedirectToAction("Login", "Pages")); } try { // Let's create a new user and fill it with form's data BL.User user = new BL.User(); user.Username = collection["Username"]; user.Password = Settings.SecureString(collection["Password"]); user.save(); return(RedirectToAction("Index")); } catch { return(View()); } }