Exemple #1
0
        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());
            }
        }
Exemple #2
0
        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());
            }
        }