Example #1
0
        public async Task <Models.UserInfo> GetByScopesAsync(Profile profile, CancellationToken ct)
        {
            var identityTypes = new List <IdentityType>
            {
                IdentityType.EmailAndPassword,
                IdentityType.PhoneAndPassword
            };

            var request = new IdentitiesGetPagedListRequest
            {
                ProfileId = profile.Id,
                Types     = identityTypes,
                Limit     = identityTypes.Count
            };

            var allIdentities = await _identitiesService.GetPagedListAsync(request, ct);

            var email = allIdentities.FirstOrDefault(x => x.Type == IdentityType.EmailAndPassword)?.Key;
            var phone = allIdentities.FirstOrDefault(x => x.Type == IdentityType.PhoneAndPassword)?.Key;

            return(new Models.UserInfo
            {
                Id = profile.Id,
                Surname = profile.Surname,
                Name = profile.Name,
                Email = email,
                Phone = phone,
                Gender = profile.Gender?.ToString().ToLower(),
                BirthDate = profile.BirthDate?.ToString("dd.MM.yyyy")
            });
        }
Example #2
0
 public Task <Models.Identity[]> GetPagedListAsync(IdentitiesGetPagedListRequest request, CancellationToken ct)
 {
     return(_storage.Identities
            .AsNoTracking()
            .Where(x =>
                   (request.ProfileId == x.ProfileId) &&
                   (request.Types == null || !request.Types.Any() || request.Types.Contains(x.Type)) &&
                   (!request.IsVerified.HasValue || x.IsVerified == request.IsVerified) &&
                   (!request.MinCreateDateTime.HasValue || x.CreateDateTime >= request.MinCreateDateTime) &&
                   (!request.MaxCreateDateTime.HasValue || x.CreateDateTime <= request.MaxCreateDateTime) &&
                   (!request.MinModifyDateTime.HasValue || x.ModifyDateTime >= request.MinModifyDateTime) &&
                   (!request.MaxModifyDateTime.HasValue || x.ModifyDateTime <= request.MaxModifyDateTime))
            .Sort(request.SortBy, request.OrderBy)
            .Skip(request.Offset)
            .Take(request.Limit)
            .ToArrayAsync(ct));
 }