/// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="user">用户注册模型</param>
        /// <returns>View</returns>
        public ActionResult Register(RegisterUser user)
        {
            if (user != null && user.PasswordQuestion != null)
            {
                if (user.PasswordQuestion == "请选择密保查询问题")
                {
                    ViewBag.PasswordQuestion = "请选择一个密保查询问题";
                }
            }
            if (!ModelState.IsValid || user == null ||
                user.VerificationCode == null || user.Email == null ||
                Session["PictureCode"] == null)
            {
                return(View("Register", user));
            }
            if (string.Compare(user.VerificationCode, Session["PictureCode"].ToString(), true) != 0)
            {
                ViewBag.VerificationCode = "验证码错误,请重试";
                return(View("Register", user));
            }
            var membershipuser = new Membership();

            membershipuser.Users          = new Users();
            membershipuser.Users.UserName = user.Email;
            membershipuser.MobilePIN      = user.Mobile;
            membershipuser.Email          = user.Email;
            membershipuser.Password       = user.Password;
            var other = new OtherInformation();

            other.Address          = "";
            other.Mobile           = user.Mobile;
            other.QQ               = user.QQ;
            other.Sex              = SexCatalog.Male;
            other.NickName         = user.NickName;
            other.PasswordQuestion = user.PasswordQuestion;
            other.PasswordAnswer   = user.PasswordAnswer;
            var entityResult = accountService.AddUser(membershipuser, other);

            if (entityResult.isSuccess)
            {
                // 跳转到登录页面
                //System.Web.Security.FormsAuthentication.SetAuthCookie(user.Email, true);
                //Session[user.Email] = user.NickName == null ? "" : user.NickName;
                var        ticket     = new System.Web.Security.FormsAuthenticationTicket(user.Email, true, 30);
                string     authTicket = System.Web.Security.FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie     = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, authTicket);
                cookie.Domain = AppSettings.FormDomain;
                var userExtend = accountService.GetUserExtendInfo(user.Email);
                Session[user.Email] = userExtend.NickName == null ? "" : userExtend.NickName;
                Response.Cookies.Add(cookie);
                gloCache.UserCountAdd();
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                ViewBag.Error = entityResult.ResultMsg;
                return(View("Register", user));
            }
        }
 private void DgOthers_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         var row_list = GetDataGridRows(dgOthers);
         foreach (DataGridRow single_row in row_list)
         {
             if (single_row.IsSelected == true)
             {
                 otherInformationSelected = single_row.DataContext as OtherInformation;
             }
         }
     }
     catch { }
 }
 public void DeleteOtherInformation(OtherInformation otherInformationSelected)
 {
     OtherInformationDeleted.Add(otherInformationSelected);
 }
示例#4
0
 public Student(string firstName, string lastName, OtherInformation otherInfo)
 {
     this.FirstName = firstName;
     this.LastName  = lastName;
     this.OtherInfo = otherInfo;
 }