Beispiel #1
0
        public ActionResult Create(FormCollection frm)
        {
            Sys_User saveUser = new Sys_User();

            saveUser.FullName = frm["FullName"];
            saveUser.Email    = frm["Email"];
            string password = frm["Password"];

            saveUser.DepartmentId = Convert.ToInt32(frm["DepartmentId"]);
            saveUser.UserType     = Convert.ToInt32(frm["UserTypeId"]);

            string passwordSalt = CryptoService.CreateSalt(10);
            string passwordHash = CryptoService.GenerateSHA256Hash(password, passwordSalt);

            saveUser.PasswordSalt = Convert.ToString(passwordSalt);
            saveUser.Password     = Convert.ToString(passwordHash);

            if (frm["IsActive"] == "Y")
            {
                saveUser.IsActive = true;
            }
            else
            {
                saveUser.IsActive = false;
            }

            saveUser.EnteredDate = DateTime.Now;
            saveUser.EnteredBy   = Convert.ToInt32(Session["UserId"]);

            db.AddUsers(saveUser);
            return(RedirectToAction("Index"));
        }