Пример #1
0
        public ActionResult Index(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                #region 注册用户并登录
                try
                {
                    Member mb = new Member();
                    mb.Email = model.Email;
                    mb.NickName = model.NickName;
                    mb.Status = 1;//注册未激活,0为禁用
                    mb.Password = CheckHelper.StrToMd5(model.Password);
                    mb.AddTime = DateTime.Now;
                    mb.LastTime = DateTime.Now;
                    mb.AddIP = HttpHelper.IP;
                    mb.LastIP = HttpHelper.IP;
                    mb.LoginCount = 1;

                    DB_Service.Add<Member>(mb);
                    DB_Service.Commit();
                    CookieHelper.LoginCookieSave(mb.MemberID.ToString(),
                        mb.Email,
                        mb.NickName,
                        "",
                        "",
                        mb.LoginCount.ToString(),
                        mb.Password, "1");
                    return Redirect(Url.Action("Index"));

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion
            }
            else
            {
                return View(model);
            }
        }
Пример #2
0
        public ActionResult Create(DetailsModel model)
        {
            var groups = GetForeignData();
            ViewBag.Data_GroupID = groups;

            if (ModelState.IsValid)
            {
                try
                {
                    Member member = new Member();
                    member.Email = model.Email;
                    member.NickName = model.NickName;
                    member.GroupID = model.GroupID;
                    member.Password = CheckHelper.StrToMd5(model.Password);
                    member.Status = 1;//注册未激活,0为禁用
                    member.AddTime = DateTime.Now;
                    member.LastTime = DateTime.Now;
                    member.AddIP = HttpHelper.IP;
                    member.LastIP = HttpHelper.IP;
                    member.Member_Profile = new Member_Profile();
                    member.Member_Profile.AvtarUrl = model.AvtarUrl;
                    member.Member_Profile.Borthday = model.Borthday;
                    member.Member_Profile.CityCode = model.CityCode;
                    member.Member_Profile.Description = model.Description;
                    member.Member_Profile.Sex = model.Sex;
                    DB_Service.Add<Member>(member);
                    DB_Service.Commit();

                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return View(model);
                }
            }
            else
            {
                return View(model);
            }
        }