Пример #1
0
        public ActionResult AddUserInfo(Users user)
        {
            string userrole  = Request["UserRoleId"];
            var    roleid    = rolebll.LoadEntities(c => c.RoleName == userrole).FirstOrDefault();
            string userstate = Request["UserStateId"];
            var    stateid   = statebll.LoadEntities(c => c.Name == userstate).FirstOrDefault();
            Users  userinfo  = new Users();

            userinfo.LoginId     = user.LoginId;
            userinfo.LoginPwd    = user.LoginPwd.Md5();
            userinfo.Name        = user.Name;
            userinfo.Address     = user.Address;
            userinfo.Phone       = user.Phone;
            userinfo.Mail        = user.Mail;
            userinfo.UserRoleId  = roleid.RoleId;
            userinfo.UserStateId = stateid.Id;
            userinfo.Money       = user.Money;
            userinfo.RegTime     = DateTime.Now;
            if (userbll.AddEntity(userinfo) != null)
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }
Пример #2
0
        public void Regist()
        {
            string email = Request["Mail"];
            string pwd   = Request["LoginPwd"];
            string repwd = Request["LoginRepwd"];
            string vcode = Request["Vcode"];

            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(repwd) && !string.IsNullOrEmpty(vcode))
            {
                if (Session["vcode"] != null && Session["vcode"].ToString() == vcode)
                {
                    var user = userbll.LoadEntities(c => c.Mail == email).FirstOrDefault();
                    if (user == null)
                    {
                        Users usermodel = new Users();
                        usermodel.Mail        = email;
                        usermodel.LoginId     = email;
                        usermodel.LoginPwd    = pwd.Md5();
                        usermodel.Name        = string.Empty;
                        usermodel.Phone       = string.Empty;
                        usermodel.Address     = string.Empty;
                        usermodel.UserRoleId  = 2;
                        usermodel.UserStateId = 1;
                        usermodel.Money       = 0;
                        usermodel.Image       = string.Empty;
                        usermodel.RegTime     = DateTime.Now;
                        Users model = userbll.AddEntity(usermodel);
                        if (model != null)
                        {
                            WebCommon.GoNext("亲,恭喜注册成功!", "登录", "/Account/Index");
                        }
                        else
                        {
                            WebCommon.GoBack("亲,注册失败了哦!");
                        }
                    }
                    else
                    {
                        WebCommon.GoBack("亲,该邮箱已存在了哦!");
                    }
                }
                else
                {
                    WebCommon.GoBack("验证码不正确!");
                }
            }
            else
            {
                WebCommon.GoBack("数据填写不完整!");
            }
        }