public IHttpActionResult GetTrades() { var result = IndustryContract.Trades.Select(m => new { m.Id, m.Name, }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
public IHttpActionResult GetPositions(int professionId) { var result = IndustryContract.Positions.Where(m => m.Profession.Id == professionId).Select(m => new { m.Id, m.Name }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
public IHttpActionResult GetPositions(int cityId) { var result = DeliveryContract.Regions.Where(m => m.City.Id == cityId).Select(m => new { m.Id, m.Name }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
/// <summary> /// 验证验证码是否正确 /// </summary> /// <param name="phoneNo">手机号码</param> /// <param name="code">验证码</param> /// <param name="codeType">验证码类型</param> /// <returns></returns> public OperationResult ValidateCode(string phoneNo, string code, CodeType codeType) { var serverCode = GetValidateCode(phoneNo, codeType); if (serverCode == null || serverCode.Code != code) { return(BodeResult.ValidError("验证码有误,请重新输入")); } return(BodeResult.Success()); }
public IHttpActionResult GetCitys(int provinceId) { var result = DeliveryContract.Citys.Where(m => m.Province.Id == provinceId).Select(m => new { m.Id, m.Name, }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
public IHttpActionResult GetProvinces() { var result = DeliveryContract.Provinces.Select(m => new { m.Id, m.Name, }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
/// <summary> /// 保存用户设置标签 /// </summary> /// <param name="userId">用户ID</param> /// <param name="ids">用户设置的标签ID</param> /// <returns></returns> public OperationResult SaveLabels(int userId, int[] ids) { ids.CheckNotNull("ids"); var user = UserInfoRepo.GetByKey(userId); if (user == null) { return(BodeResult.ValidError("用户不存在")); } user.Labels = LabelRepo.GetByPredicate(m => ids.Contains(m.Id)).ToList(); return(UserInfoRepo.Update(user) == 0 ? BodeResult.NoChanged() : BodeResult.Success()); }
public async Task <OperationResult> Login(string phoneNo, string code, LoginDevice loginDevice) { phoneNo.CheckNotNullOrEmpty("phoneNo"); code.CheckNotNullOrEmpty("code"); SysUser sUser = UserManager.FindByName(phoneNo); var severCode = GetValidateCode(phoneNo, CodeType.动态登录); if (sUser == null || sUser.UserType != UserType.App用户) { return(BodeResult.QueryNull("用户不存在")); } else if (sUser.IsLocked) { return(BodeResult.ValidError("用户已经被冻结,请联系客户.")); } else if (severCode == null || severCode.Code != code) { return(BodeResult.ValidError("验证码错误.")); } return(await Login(phoneNo, "null", loginDevice, "1.0.0")); }
public IHttpActionResult IsExistLabel() { var result = UserContract.UserInfos.Single(m => m.Id == OperatorId).Labels.Count(); return(Json((result == 0 ? BodeResult.QueryNull("用户无标签") : BodeResult.Success()).ToApiResult())); }
public IHttpActionResult GetLabels() { var result = CharacterContract.Labels.OrderBy(m => m.OrderNo).Select(m => new { m.Id, m.Name }).ToList(); return(Json(BodeResult.Success(result).ToApiResult())); }
/// <summary> /// 验证用户注册 /// </summary> /// <param name="dto">用户注册信息</param> /// <param name="validateCode">验证码</param> /// <returns>业务操作结果</returns> public async Task <OperationResult> ValidateRegister(UserInfoRegistDto dto, string validateCode) { dto.CheckNotNull("dto"); validateCode.CheckNotNullOrEmpty("validateCode"); //验证码 var severCode = GetValidateCode(dto.UserName, CodeType.用户注册); if (severCode == null || severCode.Code != validateCode) { return(BodeResult.ValidError("验证码错误")); } if (SysUserRepo.CheckExists(p => p.UserName == dto.UserName)) { return(BodeResult.ValidError("账号已被使用")); } try { UserInfoRepo.UnitOfWork.TransactionEnabled = true; //验证密码格式 IdentityResult result = await UserManager.PasswordValidator.ValidateAsync(dto.Password); if (!result.Succeeded) { return(result.ToOperationResult()); } SysUser sUser = new SysUser() { UserName = dto.UserName, NickName = dto.NickName, PasswordHash = UserManager.PasswordHasher.HashPassword(dto.Password),//密码加密 UserType = UserType.App用户 }; if (severCode.ValidateType == ValidateType.手机) { sUser.PhoneNumber = dto.UserName; sUser.PhoneNumberConfirmed = true; } else { sUser.Email = dto.UserName; sUser.EmailConfirmed = true; } await UserManager.CreateAsync(sUser); var userInfo = Mapper.Map <UserInfo>(dto); userInfo.SysUser = sUser; userInfo.Region = RegionRepo.GetByKey(dto.RegionId); userInfo.Education = EducationRepo.GetByKey(dto.EducationId); userInfo.Position = PositionRepo.GetByKey(dto.PositionId); await UserInfoRepo.InsertAsync(userInfo); await UserInfoRepo.UnitOfWork.SaveChangesAsync(); return(BodeResult.Success("注册成功", userInfo.Id)); } catch (Exception e) { return(BodeResult.NoChanged("注册失败")); } }