コード例 #1
0
        public async Task <bool> AddUserInfoAsync(UserInfoQuery user)
        {
            var returnsCode = new SqlParameter {
                SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output
            };

            return(await _contextMain.Database.ExecuteSqlCommandAsync($"addUser {user.UserId}, {user.FirstName}, {user.LastName}, {user.BirthDate}, {user.SexType}, {user.City},  {user.Description}, {user.OriginalAvatarUrl}, {returnsCode} OUT") > 0);
        }
コード例 #2
0
        public async Task <IActionResult> Get()
        {
            var identifier = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (string.IsNullOrEmpty(identifier))
            {
                return(BadRequest());
            }

            var query    = new UserInfoQuery(Guid.Parse(identifier));
            var userInfo = await _queryProcessor.ProcessAsync(query);

            return(OkResult(userInfo));
        }
コード例 #3
0
ファイル: UserInfoRepository.cs プロジェクト: nnhaigl/ico
        public List <UserInfo> GetReferralUsers(UserInfoQuery query, out int count)
        {
            var limit = query.PageSize;
            var start = (query.PageIndex - 1) * limit;

            IQueryable <UserInfo> linqQuery = Table();

            linqQuery = linqQuery.Where(x => x.ReferralUsername == query.ReferralUsername);

            count = linqQuery.Count();

            linqQuery = linqQuery.Skip(start).Take(limit);
            return(linqQuery.ToList());
        }
コード例 #4
0
        public async Task <IActionResult> List()
        {
            using (var db = AppDb.GetAppDb())
            {
                if (db == null || db.Connection == null)
                {
                    _logger.LogError("Mysql db can not create");
                    return(ResultUtil.GetFailureResult(StatusCodes.Status500InternalServerError, "Do not found mysql instance"));
                }
                var query  = new UserInfoQuery(db);
                var result = await query.LatestPostsAsync();

                return(ResultUtil.GetSuccessResult(result));
            }
        }
コード例 #5
0
        private async Task <UserDto> RegisterViaExternalSocial(NormalizedSocialUserData user, SocialType socialType)
        {
            const RoleType role = RoleType.User;

            var userDb = new UserEntity {
                Email = user.ExternalEmail, RoleType = role, RegistrationDate = DateTime.UtcNow
            };
            var isAdded = await Db.Users.AddUserAsync(userDb);

            if (!isAdded || userDb.UserId == 0)
            {
                throw new Exception("We are not able to add you. Please, tell us about it.");
            }

            var fullUrl = await UploadAvatarUrlOrGetStandard(user.OriginalPhotoUrl);

            var userInfo = new UserInfoQuery
            {
                UserId            = userDb.UserId,
                FirstName         = user.FirstName,
                LastName          = user.LastName,
                BirthDate         = user.BirthDate,
                SexType           = user.SexType,
                City              = user.City,
                OriginalAvatarUrl = fullUrl,
                Description       = ""
            };

            if (!await Db.UsersInfo.AddUserInfoAsync(userInfo))
            {
                await Db.Users.RemoveUserAsync(userDb.UserId);

                throw new Exception("We are not able to add your information. Please, tell us about it.");
            }

            if (!await AddUserSocialAsync(userDb.UserId, socialType, user))
            {
                await Db.Users.RemoveUserAsync(userDb.UserId);

                throw new Exception("We are not able to add your social information. Please, tell us about it.");
            }

            await Hub.Monitoring.AddUrlMonitoring(userDb.UserId);

            return(new UserDto {
                UserId = userDb.UserId, RoleType = userDb.RoleType
            });
        }
コード例 #6
0
        /// <summary>
        /// 获取所有的用户信息
        /// </summary>
        /// <returns>返回用户详细信息的Json对象</returns>
        public ActionResult GetAllUserInfos()
        {
            //Json格式的要求{total:22,rows:{}}

            //实现对用户分页的查询,rows:一共多少条,page:请求的当前第几页
            int pageIndex = Request["page"] == null ? 1 : int.Parse(Request["page"]);
            int pageSize  = Request["rows"] == null ? 10 : int.Parse(Request["rows"]);
            //得到多条件查询的参数
            string RealName          = Request["RealName"];
            string Telephone         = Request["Telephone"];
            string EMail             = Request["EMail"];
            int?   Enabled           = Request["Enabled"] == null ? -1 : int.Parse(Request["Enabled"]);
            string AuditStatus       = Request["AuditStatus"];
            int?   DeletionStateCode = Request["DeletionStateCode"] == null ? 0 : int.Parse(Request["DeletionStateCode"]);
            int    total             = 0;

            //调用分页的方法,传递参数,拿到分页之后的数据
            //var data = _userInfoService.LoadPageEntities(pageIndex, pageSize, out total,
            //    u => true && u.DeletionStateCode == 0, true, u => u.SortCode);

            //封装一个业务逻辑层的方法,来处理分页过滤事件
            var userInfoQuery = new UserInfoQuery()
            {
                PageSize         = pageSize,
                PageIndex        = pageIndex,
                RealName         = RealName,
                Telephone        = Telephone,
                EMail            = EMail,
                Enabled          = Enabled,
                AuditStatus      = AuditStatus,
                Total            = 0,
                DeletionStateCod = DeletionStateCode
            };
            //如果含有导航属性关联的话,出现循环引用的问题,死循环
            var data = from u in _userInfoService.LoadSearchData(userInfoQuery)
                       select new
            {
                u.ID, u.AuditStatus, u.Birthday, u.ChangePasswordDate, u.Code, u.CreateBy, u.CreateOn, u.CreateUserID,
                u.DeletionStateCode, u.DepartmentID, u.Description, u.Email, u.Enabled, u.Gender, u.HomeAddress, u.IsStaff,
                u.IsVisible, u.Mobile, u.ModifiedBy, u.ModifiedUserID, u.ModifirdOn, u.QICQ, u.QuickQuery, u.RealName,
                u.SecurityLevel, u.SortCode, u.Telephone, u.Title, u.UserFrom, u.UserName, u.UserPassword
            };
            //构造成Json的格式传递
            var result = new { total = userInfoQuery.Total, rows = data };

            //return JsonDate(result);
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        public async Task <IActionResult> Get(int id)
        {
            using (var db = AppDb.GetAppDb())
            {
                if (db == null)
                {
                    return(ResultUtil.GetFailureResult(StatusCodes.Status500InternalServerError, "Do not found mysql instance"));
                }
                var query  = new UserInfoQuery(db);
                var result = await query.FindOneAsync(id);

                if (result == null)
                {
                    return(ResultUtil.GetFailureResult(StatusCodes.Status404NotFound, "user not found"));
                }
                return(ResultUtil.GetSuccessResult(result));
            }
        }
コード例 #8
0
        public ActionResult GetBackUserInfoList()
        {
            if (CurrenUserInfo == null)
            {
                return(Json(new ResponseEntity <dynamic>(-2, "无权限", null), JsonRequestBehavior.AllowGet));
            }
            var queryParams = new NameValueCollection();

            if (!ParamHelper.CheckParaQ(ref queryParams))
            {
                return(Json(new ResponseEntity <int>(RegularFunction.RegularSqlRegexText), JsonRequestBehavior.AllowGet));
            }

            var query = new UserInfoQuery(queryParams);

            var sqlCondition = new StringBuilder();

            sqlCondition.Append("ISNULL(IsDelete,0)!=1");
            PageRequest preq = new PageRequest
            {
                TableName      = " [BackUserInfo] ",
                Where          = sqlCondition.ToString(),
                Order          = " Id DESC ",
                IsSelect       = true,
                IsReturnRecord = true,
                PageSize       = query.PageSize,
                PageIndex      = query.PageIndex,
                FieldStr       = "*"
            };

            var result = new BackUserInfoBLL().GetDataByPage(preq);

            var response = new ResponseEntity <object>(true, string.Empty,
                                                       new DataGridResultEntity <BackUserInfo>
            {
                TotalRecords   = preq.Out_AllRecordCount,
                DisplayRecords = preq.Out_PageCount,
                ResultData     = result
            });

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public async Task <IActionResult> Delete(int id)
        {
            using (var db = AppDb.GetAppDb())
            {
                if (db == null)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Do not found mysql instance"));
                }
                await db.Connection.OpenAsync();

                var query  = new UserInfoQuery(db);
                var result = await query.FindOneAsync(id);

                if (result == null)
                {
                    return(new NotFoundResult());
                }
                await result.DeleteAsync();

                return(new OkResult());
            }
        }
コード例 #10
0
        public (List <UserQuery> users, List <UserInfoQuery> userInfos) CreateUsers(List <User> users)
        {
            var userQueries     = new List <UserQuery>();
            var userInfoQueries = new List <UserInfoQuery>();

            foreach (var user in users)
            {
                var userQuery = new UserQuery
                {
                    Email                            = user.Email,
                    IsBot                            = user.IsBot,
                    IsEmailConfirmed                 = user.IsEmailConfirmed,
                    IsPhoneNumberConfirmed           = user.IsPhoneNumberConfirmed,
                    IsTwoFactorAuthenticationEnabled = user.IsTwoFactorAuthenticationEnabled,
                    PasswordHash                     = user.PasswordHash,
                    PhoneNumber                      = user.PhoneNumber,
                    RegistrationDate                 = user.RegistrationDate,
                    RoleType                         = user.RoleType,
                    UserId                           = user.UserId
                };
                var userInfoQuery = new UserInfoQuery
                {
                    UserId            = user.UserId,
                    BirthDate         = user.BirthDate,
                    City              = user.City,
                    Description       = user.Description,
                    FirstName         = user.FirstName,
                    LastName          = user.LastName,
                    OriginalAvatarUrl = user.OriginalAvatarUrl,
                    SexType           = user.SexType
                };
                userQueries.Add(userQuery);
                userInfoQueries.Add(userInfoQuery);
            }

            return(userQueries, userInfoQueries);
        }
コード例 #11
0
        public async Task <IActionResult> Update(int id, [FromBody] UserInfo body)
        {
            using (var db = AppDb.GetAppDb())
            {
                if (db == null)
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Do not found mysql instance"));
                }
                var query  = new UserInfoQuery(db);
                var result = await query.FindOneAsync(id);

                if (result == null)
                {
                    return(new NotFoundResult());
                }
                result.Name    = body.Name;
                result.Address = body.Address;
                result.Age     = body.Age;
                result.Gender  = body.Gender;
                await result.UpdateAsync();

                return(new OkObjectResult(result));
            }
        }
コード例 #12
0
        public async Task <Token> RegisterAsync(UserRegistrationViewModel user)
        {
            Logger.LogInformation($"{nameof(InternalAuthService)}.{nameof(RegisterAsync)}.Start");
            var isExistByPhone = !user.Phone.IsNullOrEmpty() && await Db.Users.IsUserExistByPhoneAsync(user.Phone);

            var isExistByEmail = !user.Email.IsNullOrEmpty() && await Db.Users.IsUserExistByEmailAsync(user.Email);

            if (isExistByEmail || isExistByPhone)
            {
                throw new Exception("You have already registered.");
            }

            const RoleType role = RoleType.User;

            var userDb = new UserEntity
            {
                Email            = user.Email,
                PhoneNumber      = user.Phone,
                RoleType         = role,
                PasswordHash     = user.Password.GetMd5HashString(),
                RegistrationDate = DateTime.UtcNow,
            };
            var isAdded = await Db.Users.AddUserAsync(userDb);

            if (!isAdded || userDb.UserId == 0)
            {
                throw new Exception("We are not able to add you. Please, tell us about it.");
            }

            string firstName;
            string lastName;

            var spacePosition = user.Login.IndexOf(' ');

            if (spacePosition == -1)
            {
                firstName = user.Login.Substring(0, user.Login.Length);
                lastName  = "";
            }
            else
            {
                firstName = user.Login.Substring(0, spacePosition);
                lastName  = user.Login.Substring(spacePosition + 1).Trim();
            }
            var userInfo = new UserInfoQuery
            {
                UserId            = userDb.UserId,
                FirstName         = firstName,
                LastName          = lastName,
                BirthDate         = user.BirthDate,
                SexType           = user.SexType,
                City              = user.City,
                Description       = user.Description ?? "",
                OriginalAvatarUrl = (await Hub.Media.GetStandardAvatarUrls(AvatarSizeType.Original)).FirstOrDefault() ?? ""
            };

            if (!await Db.UsersInfo.AddUserInfoAsync(userInfo))
            {
                await Db.Users.RemoveUserAsync(userDb.UserId);

                throw new Exception("We are not able to add your information. Please, tell us about it.");
            }

            //await Hub.Monitoring.AddUrlMonitoring(userDb.UserId);

            var jwtToken = await JwtService.GenerateJwtAsync(userDb.UserId, role);

            var token = new TokenEntity
            {
                UserId       = userDb.UserId,
                ExpiresIn    = jwtToken.ExpiresIn,
                RefreshToken = jwtToken.RefreshToken
            };

            // SendConfirmedEmail(userDb.UserId, role, userDb.Email);

            if (!await Db.Tokens.AddTokenAsync(token))
            {
                throw new Exception("Can not add token to database. You entered just as a guest.");
            }
            Logger.LogInformation($"{nameof(InternalAuthService)}.{nameof(RegisterAsync)}.End");
            return(jwtToken);
        }
コード例 #13
0
 public WxPayGateway()
 {
     _userInfoQuery = new UserInfoQuery();
 }
コード例 #14
0
ファイル: PaymentGateway.cs プロジェクト: a498497672/Ticket
 public PaymentGateway()
 {
     _userInfoQuery = new UserInfoQuery();
 }
コード例 #15
0
 private string GetInsertionUserInfoLine(UserInfoQuery userInfo)
 {
     return
         ($"EXECUTE [dbo].[addUser] {userInfo.UserId}, N'{userInfo.FirstName}', N'{userInfo.LastName}', '{userInfo.BirthDate:u}', {(int)userInfo.SexType}, N'{userInfo.City}', N'{userInfo.Description}', N'{userInfo.OriginalAvatarUrl}'");
 }
コード例 #16
0
 public BaseListResponse <UserInfo> GetReferralUsers(UserInfoQuery query)
 {
     query.ReferralUsername = UserHeader();
     return(_userService.GetReferralUsers(query));
 }