예제 #1
0
        public ActionResult Create([Bind(Include = "Id,UserName,Pwd,Salt,Code,PwdExpire,LastName,FirstName,Email,Mobile,LocationId,UserGroupId,UserCode1,UserCode2,UserCode3,UserCode4,UserCode5,DateAdded,LastUpdated,Statusflag,Slug")] User user)
        {
            if (ModelState.IsValid)
            {
                user.Salt = GenUtil.RandomLower(15);
                user.Pwd  = CryptUtil.Enkrypt(user.UserName + user.Pwd + user.Salt);
                user.Code = "0";

                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LocationId  = new SelectList(db.Locations, "Id", "LocationName", user.LocationId);
            ViewBag.UserGroupId = new SelectList(db.UserGroups, "Id", "UserGroupName", user.UserGroupId);
            return(View(user));
        }