public static CurrentUser GetCurrentUserByTuser(UserDto user) { var currentUser = new CurrentUser(); currentUser.SystemLevel = 1; currentUser.LoginAccount = user.LoginAccount; currentUser.UserID = new Guid(user.Id); currentUser.UserName = user.UserName; return currentUser; }
public ActionResult CreateOrders(ProductDto porduct, int? count) { var currentUser = CurrentOperator; var userDto = new UserDto() { Id = CurrentOperator.UserID.ToString() }; _orderServiceImp.CreateOrderDirect(userDto, porduct, count ?? 0); return Alert("下单成功","/zhongzhuan?note=下单成功!立即支付?&url=/lijizhifu");//需要跳转到待付款界面吧? }
/// <summary> /// 用户注册逻辑 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult CreateUser(UserDto user) { if (user != null) { var list = new List<UserDto>(); list.Add(user); _userServiceImp.CreateUsers(list); UserLogin(user);//注册完毕直接登录 } //这里应该跳转到注册完毕的页面 return RedirectToAction("UserHaveRegisted", new { LoginAccount = user.LoginAccount }); }
public bool EnableUser(UserDto userDto) { if (userDto == null) throw new ArgumentNullException("userDto"); User user; if (!IsEmptyGuidString(userDto.Id)) user = _userRepository.GetByKey(new Guid(userDto.Id)); else if (!string.IsNullOrEmpty(userDto.UserName)) user = _userRepository.GetByExpression(u => u.UserName == userDto.UserName); else if (!string.IsNullOrEmpty(userDto.Email)) user = _userRepository.GetByExpression(u => u.Email == userDto.Email); else throw new ArgumentNullException("userDto", "Either ID, UserName or Email should be specified."); user.Enable(); _userRepository.Update(user); RepositorytContext.Commit(); return user.IsDisabled; }
public OrderDto CreateOrderDirect(UserDto userDto, ProductDto productDto, int quantity) { var user = _userRepository.GetByKey(new Guid(userDto.Id)); var product=_productRepository.GetByKey(new Guid(productDto.Id)); if (user!=null) { var order = _domainService.CreateOrderDirect(user, product,quantity); return Mapper.Map<OrderDto>(order); } return null; }
public OrderDto CheckOutByItem(UserDto userDto, List<ShoppingCartItemDto> shopItems) { var user = _userRepository.GetByKey(new Guid(userDto.Id)); //var shoppingCart = _shoppingCartRepository.GetByExpression(s => s.User.Id == user.Id); var list = shopItems.ConvertAll(x => { return Mapper.Map<ShoppingCartItemDto, ShoppingCartItem>(x); }); var order = _domainService.CreateOrderByItem(user, list); return Mapper.Map<OrderDto>(order); }
/// <summary> /// 用户登录action /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult UserLoginFromPage(UserDto user) { UserLogin(user); return Redirect("http://www.tutgou.com"); }
public void UserLogin(UserDto user) { var tUser = _userServiceImp.GetUserByLoginAccount(user.LoginAccount); if (tUser.Password.Equals(user.Password))//登录成功 { if (tUser.IsDisabled.Value)//说明不可用 { //待定 return; } var currentUser = CustomUserSession.GetCurrentUserByTuser(tUser);//获取当前登录用户信息 CustomUserSession.SaveSessionForLogin(currentUser); } }
/// <summary> /// 用户注册成功后中转页面 /// </summary> /// <param name="user"></param> /// <returns></returns> public ActionResult UserHaveRegisted(UserDto user) { var tUser = _userServiceImp.GetUserByLoginAccount(user.LoginAccount); ViewData["userName"] = tUser.UserName; return View(); }