示例#1
0
文件: ChariDb.cs 项目: ichari/ichari
 /// <summary>
 /// 用于向 UserInfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUserInfo(UserInfo userInfo)
 {
     base.AddObject("UserInfo", userInfo);
 }
示例#2
0
        public ActionResult ClaimPrize(WinningRegistration winReg)
        {
            if (Session[SessionKey.Captcha] == null || Session[SessionKey.Captcha].ToString() != winReg.Captcha)
            {
                ModelState.AddModelError("Captcha", "验证码不正确");
            }
            if (Session[SessionKey.DrawId] == null)
            {
                return RedirectToAction("Error");
            }
            if (ModelState.IsValid)
            {
                List<UserInfo> eusr = _uow.UserInfoService.GetList(t => t.UserName == winReg.UserName).ToList();
                if (eusr.Count == 0)
                {
                    UserInfo usr = new UserInfo();
                    string pwdplain = winReg.Password;
                    usr.RegFrom = 1;
                    usr.UserName = winReg.UserName;
                    usr.Password = DataEncryption.HashString(pwdplain);
                    usr.TrueName = winReg.Name;
                    usr.Email = winReg.Email;
                    usr.Phone = winReg.Cell;
                    usr.Tel = winReg.Tel;
                    usr.CreateTime = DateTime.Now;
                    usr.UpdateTime = DateTime.Now;
                    _uow.UserInfoService.Add(usr);
                    _uow.Commit();

                    UserInfo u = _uow.UserInfoService.Get(o => o.UserName == o.UserName && o.Password == usr.Password);
                    Address addr = new Address();
                    addr.UserId = u.Id;
                    addr.Address1 = winReg.Street;
                    addr.City = winReg.City;
                    addr.Email = winReg.Email;
                    addr.Mobile = winReg.Cell;
                    addr.PostCode = winReg.Postal;
                    addr.Province = winReg.Province;
                    addr.Tel = winReg.Tel;
                    addr.TrueName = winReg.Name;
                    _uow.AddressService.Add(addr);
                    _uow.Commit();

                    long drawId = long.Parse((string)Session[SessionKey.DrawId]);
                    Drawings dr = _uow.DrawingsService.Get(o => o.Id == drawId);
                    Address ad = _uow.AddressService.Get(o => o.UserId == u.Id && o.Address1 == winReg.Street && o.City == winReg.City && o.PostCode == winReg.Postal);
                    dr.IsConfirrmed = true;
                    dr.AddressId = ad.Id;
                    
                    _uow.Commit();
                    Session[SessionKey.User] = usr;
                    Session[SessionKey.DrawId] = dr.Id;
                    Session[SessionKey.PrizeId] = dr.PrizeId;

                    return RedirectToAction("ClaimConfirmation");
                }
                else
                {
                    ModelState.AddModelError("UserName", "用户名已使用");
                }
            }

            return View(winReg);
        }
示例#3
0
文件: ChariDb.cs 项目: ichari/ichari
 /// <summary>
 /// 创建新的 UserInfo 对象。
 /// </summary>
 /// <param name="id">Id 属性的初始值。</param>
 /// <param name="userName">UserName 属性的初始值。</param>
 /// <param name="password">Password 属性的初始值。</param>
 /// <param name="regFrom">RegFrom 属性的初始值。</param>
 /// <param name="createTime">CreateTime 属性的初始值。</param>
 /// <param name="updateTime">UpdateTime 属性的初始值。</param>
 /// <param name="lotteryUserId">LotteryUserId 属性的初始值。</param>
 public static UserInfo CreateUserInfo(global::System.Int64 id, global::System.String userName, global::System.String password, global::System.Int32 regFrom, global::System.DateTime createTime, global::System.DateTime updateTime, global::System.Int64 lotteryUserId)
 {
     UserInfo userInfo = new UserInfo();
     userInfo.Id = id;
     userInfo.UserName = userName;
     userInfo.Password = password;
     userInfo.RegFrom = regFrom;
     userInfo.CreateTime = createTime;
     userInfo.UpdateTime = updateTime;
     userInfo.LotteryUserId = lotteryUserId;
     return userInfo;
 }