public void RegisterRequestMobile(string mobile) { var manager = new UserMobileManager(); var other = manager.GetMobileInfoByMobile(mobile); if (other != null && other.IsSettedMobile) { throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户注册。", mobile)); } }
/// <summary> /// 手机号是否已注册 /// </summary> /// <param name="mobile"></param> /// <returns></returns> public bool HasMobile(string mobile) { var manager = new UserMobileManager(); { var model = manager.GetMobileInfoByMobile(mobile); if (model == null) { return(false); } return(true); } }
public string RegisterResponseMobile(string userId, string mobile, int delaySeconds, string delayDescription) { try { DB.Begin(); TaskList(userId); var manager = new UserMobileManager(); var entity = manager.GetUserMobile(userId); if (entity != null) { if (entity.IsSettedMobile) { throw new LogicException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证。", entity.UpdateTime)); } var span = DateTime.Now - entity.UpdateTime.AddSeconds(delaySeconds); if (span.TotalSeconds > 0) { throw new LogicException(string.Format("提交认证手机必须在请求认证后【{0}】内完成。", delayDescription)); } entity.IsSettedMobile = true; manager.UpdateUserMobile(entity); } else { entity = new E_Authentication_Mobile { UserId = userId, CreateTime = DateTime.Now, UpdateTime = DateTime.Now, AuthFrom = "LOCAL", Mobile = mobile, IsSettedMobile = true, CreateBy = userId, UpdateBy = userId, }; manager.AddUserMobile(entity); } mobile = entity.Mobile; DB.Commit(); } catch (Exception ex) { DB.Rollback(); throw ex; } return(mobile); }
public string ResponseAuthenticationMobile(string userId, int delaySeconds, string delayDescription) { string mobile; try { DB.Begin(); TaskList(userId); var manager = new UserMobileManager(); var entity = manager.GetUserMobile(userId); if (entity == null) { throw new LogicException("尚未请求手机认证"); } if (entity.IsSettedMobile) { throw new LogicException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证。", entity.UpdateTime)); } var span = DateTime.Now - entity.UpdateTime.AddSeconds(delaySeconds); if (span.TotalSeconds > 0) { throw new LogicException(string.Format("提交认证手机必须在请求认证后【{0}】内完成。", delayDescription)); } entity.IsSettedMobile = true; manager.UpdateUserMobile(entity); mobile = entity.Mobile; DB.Commit(); } catch (Exception ex) { DB.Rollback(); throw ex; } return(mobile); }