public ActionResult ClaimPrizeStep2(AddressValidation av,int? selectedAddr) { if (selectedAddr.HasValue) { var dr = _uow.DrawingsService.Get(o => o.Id == av.DrawId.Value); if (dr == null) throw new IchariException(string.Format("未找到相应的抽奖记录:drawId={0}",av.DrawId)); dr.AddressId = selectedAddr.Value; _uow.Commit(); return RedirectToAction("DrawDetail", "Account", new { id = dr.Id }); } if (ModelState.IsValid) { var usr = base.CurrentUser; if (_uow.UserInfoService.Get(o => o.Id == usr.Id && o.UserName == usr.UserName && o.Password == usr.Password) != null) { Address addr = new Address(); addr.UserId = usr.Id; addr.Address1 = av.Street; addr.Area = av.Area; addr.City = av.City; addr.Email = av.Email; addr.Mobile = av.Cell; addr.PostCode = av.Postal; addr.Province = av.Province; addr.Tel = av.Tel; addr.TrueName = av.Name; _uow.AddressService.Add(addr); _uow.Commit(); long drId = av.DrawId ?? 0; //long.Parse((string)Session[SessionKey.DrawId]); Drawings dr = _uow.DrawingsService.Get(o => o.Id == drId); dr.AddressId = addr.Id; dr.IsHandled = true; _uow.Commit(); return RedirectToAction("DrawDetail", "Account", new { id = dr.Id }); } } return View(); }
/// <summary> /// 创建新的 Address 对象。 /// </summary> /// <param name="id">Id 属性的初始值。</param> /// <param name="userId">UserId 属性的初始值。</param> /// <param name="trueName">TrueName 属性的初始值。</param> /// <param name="mobile">Mobile 属性的初始值。</param> /// <param name="isDefault">IsDefault 属性的初始值。</param> public static Address CreateAddress(global::System.Int64 id, global::System.Int64 userId, global::System.String trueName, global::System.String mobile, global::System.Boolean isDefault) { Address address = new Address(); address.Id = id; address.UserId = userId; address.TrueName = trueName; address.Mobile = mobile; address.IsDefault = isDefault; return address; }
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); }
/// <summary> /// 用于向 Address EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToAddress(Address address) { base.AddObject("Address", address); }