Ejemplo n.º 1
0
 public BusStationService(
     IBusStationRepository busStationRepository,
     AppCacheHelper appCacheHelper,
     IMapper mapper)
     : base(mapper)
 {
     _busStationRepository = busStationRepository;
     _appCacheHelper       = appCacheHelper;
 }
Ejemplo n.º 2
0
 public RouteService(
     AppUserManager userManager,
     IRouteRepository routeRepository,
     IProjectRouteRepository projectRouteRepository,
     AppCacheHelper appCacheHelper,
     IMapper mapper)
     : base(mapper)
 {
     _routeRepository        = routeRepository;
     _userManager            = userManager;
     _projectRouteRepository = projectRouteRepository;
     _appCacheHelper         = appCacheHelper;
 }
Ejemplo n.º 3
0
 public NewRouteService(
     INewRouteRepository newRouteRepository,
     INewBusStationRouteRepository newBusStationRouteRepository,
     DictionariesCacheHelper dictionariesCacheHelper,
     AppCacheHelper appCacheHelper,
     ETagCacheHelper eTagCacheHelper,
     IMapper mapper)
     : base(mapper)
 {
     _appCacheHelper               = appCacheHelper;
     _eTagCacheHelper              = eTagCacheHelper;
     _newRouteRepository           = newRouteRepository;
     _newBusStationRouteRepository = newBusStationRouteRepository;
     _dictionariesCacheHelper      = dictionariesCacheHelper;
 }
Ejemplo n.º 4
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (Session["mobileCode"] == null)
            {
                ModelState.AddModelError(String.Empty, "手机验证码已过期");
                return(View(model));
            }
            if (Session["mobileCode"].ToString() != model.MobileCode)
            {
                ModelState.AddModelError(String.Empty, "手机验证码错误");
                return(View(model));
            }

            //如果用户不存在则创建
            var user = await _userService.GetUserByUserNameAsync(model.Mobile);

            if (user == null)
            {
                var role = _systemService.GetRoleByName(AppCacheHelper.GetSetting(AppConsts.SettingKeyUserDefaultRole));
                if (role != null)
                {
                    var password      = Session["mobileCode"].ToString();
                    var createdResult = _userService.CreateUser(new UserDto
                    {
                        UserName        = model.Mobile,
                        Password        = password.ToString(),
                        ConfrimPassword = password.ToString(),
                        Mobile          = model.Mobile,
                        OpenId          = Session["openid"] != null ? Session["openid"].ToString() : "",
                        RoleId          = new List <Guid> {
                            role.Id
                        }
                    });

                    user = createdResult.model;
                }
            }
            else
            {
                await _userService.ChangeUserPassword(user.Id, Session["mobileCode"].ToString());
            }

            Session["mobileCode"] = null;

            return(new RedirectResult("/account/login?success=true"));
        }
Ejemplo n.º 5
0
        public HttpResponseMessage GetUserInit()
        {
            var curUser  = _userService.GetUserById(AppSession.UserId.Value);
            var initData = "var WebPlus = " + JsonConvert.SerializeObject(new
            {
                config = AppCacheHelper.GetSettings(),
                user   = new
                {
                    curUser.UserName,
                    curUser.Email,
                    curUser.Mobile,
                    curUser.LoginLogs.Count
                },
                dictionarys = GetDictionarys()
            });

            return(new HttpResponseMessage {
                Content = new StringContent(initData, Encoding.GetEncoding("UTF-8"), "application/json")
            });
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> SaveOrder(OrderDto dto)
        {
            if (!AppSession.IsLogin)
            {
                if (Session["mobileCode"] == null)
                {
                    return(Json(new OperationResult {
                        success = false, message = "手机验证码已过期,请点击上一步重新获取"
                    }));
                }
                if (Session["mobileCode"].ToString() != dto.MobileCode)
                {
                    return(Json(new OperationResult {
                        success = false, message = "手机验证码错误,请点击上一步重新获取"
                    }));
                }
            }

            //如果用户不存在则创建
            var user = await _userService.GetUserByUserNameAsync(dto.Mobile);

            if (user == null)
            {
                var role = _systemService.GetRoleByName(AppCacheHelper.GetSetting(AppConsts.SettingKeyUserDefaultRole));
                if (role != null)
                {
                    var password      = Session["mobileCode"].ToString();
                    var createdResult = await _userService.CreateUserAsync(new UserDto
                    {
                        UserName        = dto.Mobile,
                        Password        = password.ToString(),
                        ConfrimPassword = password.ToString(),
                        Mobile          = dto.Mobile,
                        OpenId          = Session["openid"] == null ? "" : Session["openid"].ToString(),
                        RoleId          = new List <Guid> {
                            role.Id
                        }
                    });

                    user = createdResult.model;
                }
            }
            else
            {
                if (Session["mobileCode"] != null)
                {
                    await _userService.ChangeUserPassword(user.Id, Session["mobileCode"].ToString());
                }
                if (Session["openid"] != null)
                {
                    await _userService.ChangeUserOpenId(user.Id, Session["openid"].ToString());
                }
            }

            if (!AppSession.IsLogin || (AppSession.IsLogin && AppSession.UserId != user.Id))
            {
                //用该用户登录
                AutoLogin(user);
            }

            var redeemCode = await _goodsPackageService.GetRedeemCodeBySNAsync(dto.RedeemCode);

            if (redeemCode == null)
            {
                return(Json(new OperationResult {
                    success = false, message = "兑换码不存在"
                }));
            }
            if (redeemCode.IsExchange)
            {
                return(Json(new OperationResult {
                    success = false, message = "该兑换码已经兑换过,不能再次使用"
                }));
            }

            var result = await _orderService.CreateOrder(dto, user.Id);

            if (result.success)
            {
                Session["mobileCode"] = null;
            }

            return(Json(result));
        }