public virtual Task <List <EntityDynamicParameterValue> > GetValuesAsync(int entityDynamicParameterId, string entityId) { return(_asyncQueryableExecuter.ToListAsync( _entityDynamicParameterValueRepository.GetAll() .Where(val => val.EntityId == entityId && val.EntityDynamicParameterId == entityDynamicParameterId) )); }
public virtual Task <List <DynamicEntityPropertyValue> > GetValuesAsync(int dynamicEntityPropertyId, string entityId) { return(_asyncQueryableExecuter.ToListAsync( _dynamicEntityPropertyValueRepository.GetAll() .Where(val => val.EntityId == entityId && val.DynamicEntityPropertyId == dynamicEntityPropertyId) )); }
public async Task <IEnumerable <IdentityResource> > FindIdentityResourcesByScopeNameAsync(IEnumerable <string> scopeNames) { var names = scopeNames.ToArray(); var resources = await _asyncQueryableExecuter.ToListAsync(_identityResourceRepository.GetAll() .Include(x => x.UserClaims) .Where(x => names.Contains(x.Name))); Logger.DebugFormat("Found {0} identity scopes in database", resources.Select(x => x.Name)); return(ObjectMapper.Map <IEnumerable <IdentityResource> >(resources)); }
public async Task <List <DynamicEntityProperty> > GetAllAsync() { return(await _unitOfWorkManager.WithUnitOfWorkAsync(async() => { return await _asyncQueryableExecuter.ToListAsync( _dynamicEntityPropertyRepository .GetAllIncluding(e => e.DynamicProperty) .OrderBy(edp => edp.EntityFullName) .ThenBy(edp => edp.DynamicPropertyId) ); })); }
public virtual async Task <IEnumerable <ApiResource> > FindApiResourcesByScopeAsync(IEnumerable <string> scopeNames) { var names = scopeNames.ToArray(); var api = await _asyncQueryableExecuter.ToListAsync(_apiResourceRepository.GetAll() .Include(x => x.Secrets) .Include(x => x.Scopes) .ThenInclude(s => s.UserClaims) .Include(x => x.UserClaims) .Where(x => x.Scopes.Where(y => names.Contains(x.Name)).Any())); Logger.DebugFormat("Found {0} API scopes in database", api.SelectMany(x => x.Scopes).Select(x => x.Name)); return(ObjectMapper.Map <IEnumerable <ApiResource> >(api)); }
public async Task <LockupsDto> GetLockupsAsync(int countryId = 0, int stateId = 0) { var stateList = new List <State>(); var cityList = new List <City>(); var countryList = await _countryRepository.GetListAsync(); if (countryId > 0) { var stateQuery = _stateRepository.Where(s => s.Country.Id == countryId); stateList = await _asyncExecuter.ToListAsync(stateQuery); var cityQuery = _cityRepository.Where(c => c.State.Id == stateId); cityList = await AsyncExecuter.ToListAsync(cityQuery); } var doctorSpecialestList = await _doctorSpecialestRepository.GetListAsync(); var doctorTitleList = await _doctorTitleRepository.GetListAsync(); var result = new LockupsDto { Country = ObjectMapper.Map <List <Country>, List <CountryDto> >(countryList), State = ObjectMapper.Map <List <State>, List <StateDto> >(stateList), City = ObjectMapper.Map <List <City>, List <CityDto> >(cityList), DoctorSpecialty = ObjectMapper.Map <List <DoctorSpecialty>, List <DoctorSpecialtyDto> >(doctorSpecialestList), DoctorTitle = ObjectMapper.Map <List <DoctorTitle>, List <DoctorTitleDto> >(doctorTitleList), }; return(result); }
public async Task <ICollection <Guid> > GetBookmarks(Guid userId) { var query = _bookmarksRepository.Where(d => d.UserId == userId); var result = await _asyncQueryExecutor.ToListAsync(query); return(result.Select(d => d.ArticleId).ToList()); }
public async Task <ListResultDto <ProductDto> > GetListAsync(string name) { var query = _productRepository.Where(x => x.name.Contains(name)).OrderBy(x => x.name); List <Product> products = await _asyncExecuter.ToListAsync(query); return(new ListResultDto <ProductDto>(ObjectMapper.Map <List <Product>, List <ProductDto> >(products))); }
public async Task <IList <string> > GetRolesAsync(TUser user) { var query = from userRole in _userRoleRepository.FindAll() join role in _roleRepository.FindAll() on userRole.RoleId equals role.Id where userRole.UserId == user.Id select role.Name; return(await AsyncQueryableExecuter.ToListAsync(query)); }
public virtual async Task <IEnumerable <string> > GetRunnableInstances(DateTime asAt) { var now = asAt.ToUniversalTime().Ticks; var query = _workflowRepository.GetAll().Where(x => x.NextExecution.HasValue && (x.NextExecution <= now) && (x.Status == WorkflowStatus.Runnable)) .Select(x => x.Id); var raw = await _asyncQueryableExecuter.ToListAsync(query); return(raw.Select(s => s.ToString()).ToList()); }
public virtual async Task <bool> IsOriginAllowedAsync(string origin) { var origins = await _asyncQueryableExecuter.ToListAsync(_repository.GetAll().SelectMany(x => x.AllowedCorsOrigins.Select(y => y.Origin))); var distinctOrigins = origins.Where(x => x != null).Distinct(); var isAllowed = distinctOrigins.Contains(origin, StringComparer.OrdinalIgnoreCase); Logger.DebugFormat("Origin {0} is allowed: {1}", origin, isAllowed); return(isAllowed); }
//TODO: No need to virtual once we implement UOW filter for AspNet Core! public virtual async Task <ListResultDto <TicketDto> > GetAll(GetAllTicketsInput input) { var tickets = await _asyncQueryableExecuter.ToListAsync(_ticketRepository .WhereIf( !input.Filter.IsNullOrWhiteSpace(), t => t.Title.Contains(input.Filter) || t.Body.Contains(input.Filter) ) ); return(new ListResultDto <TicketDto>( ObjectMapper.Map <List <Ticket>, List <TicketDto> >(tickets) )); }
public async Task <PagedResultDto <HotelSearchResultDto> > GetHotelListAsync(HotelSearchQueryDto input) { if (input.Sorting.IsNullOrWhiteSpace()) { input.Sorting = nameof(Hotel.Name); } var query = _hotelRepository .OrderBy(input.Sorting) .Skip(input.SkipCount) .Take(input.MaxResultCount); var totalCount = await _asyncExecuter.CountAsync(query); var hotels = await _asyncExecuter.ToListAsync(query); var hotelsDto = ObjectMapper.Map <List <Hotel>, List <HotelSearchResultDto> >(hotels); return(new PagedResultDto <HotelSearchResultDto>( totalCount, hotelsDto )); }
public async Task <ListResultDto <UserCouponDto> > GetPublicListAsync(CouponResultRequestDto input) { var query = base.CreateFilteredQuery(input) .Where(x => x.OwnerUserId == CurrentUser.Id); var totalCount = await _asyncQueryableExecuter.CountAsync(query); query = ApplySorting(query, input); var entities = await _asyncQueryableExecuter.ToListAsync(query); return(new ListResultDto <UserCouponDto>( entities.Select(MapToGetListOutputDto).ToList() )); }
public async Task <IPagedResult <WebhookSendAttempt> > GetAllSendAttemptsBySubscriptionAsPagedListAsync(long?tenantId, Guid subscriptionId, int maxResultCount, int skipCount) { using (_unitOfWorkManager.Current.SetTenantId(tenantId)) { var query = _webhookSendAttemptRepository.GetAllIncluding(false, attempt => attempt.WebhookEvent) .Where(attempt => attempt.WebhookSubscriptionId == subscriptionId ); var totalCount = await _asyncQueryableExecuter.CountAsync(query); var list = await _asyncQueryableExecuter.ToListAsync(query .OrderByDescending(attempt => attempt.CreationTime) .Skip(skipCount) .Take(maxResultCount) ); return(new PagedResultDto <WebhookSendAttempt>() { TotalCount = totalCount, Items = list }); } }
public async Task <PagedResultDto <ProductOrderDto> > GetPublicListAsync(MallRequestDto input) { var query = CreateFilteredQuery(input) .Where(x => x.CreatorId == CurrentUser.Id) .WhereIf(input.State.HasValue && input.State == 1, x => x.PayType == MallEnums.PayType.未支付) .WhereIf(input.State.HasValue && input.State == 2, x => x.PayType != MallEnums.PayType.未支付 && x.State != MallEnums.OrderState.完成) .WhereIf(input.State.HasValue && input.State == 3, x => x.PayType != MallEnums.PayType.未支付 && x.State == MallEnums.OrderState.完成) .WhereIf(input.State.HasValue && input.State == 4, x => x.PayType != MallEnums.PayType.未支付 && x.State == MallEnums.OrderState.售后) ; var totalCount = await _asyncQueryableExecuter.CountAsync(query); query = ApplySorting(query, input); query = ApplyPaging(query, input); var entities = await _asyncQueryableExecuter.ToListAsync(query); var result = new PagedResultDto <ProductOrderDto>( totalCount, entities.Select(MapToGetListOutputDto).ToList() ); var shopDictionary = new Dictionary <Guid, MallShopDto>(); foreach (var dto in result.Items) { if (dto.ShopId.HasValue) { if (!shopDictionary.ContainsKey(dto.ShopId.Value)) { var shop = await _mallShopLookupService.FindByIdAsync(dto.ShopId.Value); if (shop != null) { shopDictionary[shop.Id] = ObjectMapper.Map <MallShop, MallShopDto>(shop); } } if (shopDictionary.ContainsKey(dto.ShopId.Value)) { dto.Shop = shopDictionary[(Guid)dto.ShopId]; } } } return(result); }
public async Task <ListResultDto <CouponDto> > GetPublishListAsync(MallRequestDto input) { var query = base.CreateFilteredQuery(input); var totalCount = await _asyncQueryableExecuter.CountAsync(query); query = ApplySorting(query, input); var entities = await _asyncQueryableExecuter.ToListAsync(query); var result = new ListResultDto <CouponDto>( entities.Select(MapToGetListOutputDto).ToList() ); return(result); }
public async Task <PagedResultDto <CommentDto> > GetPublishListAsync(MallRequestDto input) { var query = base.CreateFilteredQuery(input); var totalCount = await query.CountAsync(); query = query.OrderBy(input.Sorting ?? "id desc"); query = query.PageBy(input); var entities = await _asyncQueryableExecuter.ToListAsync(query); return(new PagedResultDto <CommentDto>( totalCount, entities.Select(MapToGetListOutputDto).ToList() )); }
public async Task <PagedResultDto <TestDto> > GetPagedListAsync(int pageIndex, int pageSize) { var qry = _testRepository.GetAll().WhereIf(true, x => x.Name.StartsWith("Jack")); //用WhereIf添加过滤条件 qry = qry.WhereIf(true, x => x.Name.StartsWith("Jack")); qry = qry.WhereIf(true, x => x.Age > 20); var totalCount = await _asyncQueryableExecuter.CountAsync(qry); var list = await _asyncQueryableExecuter.ToListAsync(qry.PageBy(pageIndex, pageSize)); var items = _mapper.Map <List <TestDto> >(list); return(new PagedResultDto <TestDto>(totalCount, items)); }
public override async Task <PagedResultDto <AddressDto> > GetListAsync(PagedAndSortedResultRequestDto input) { await CheckGetListPolicyAsync(); var query = CreateFilteredQuery(input); var totalCount = await _asyncQueryableExecuter.CountAsync(query); query = ApplySorting(query, input); query = ApplyPaging(query, input); var entities = await _asyncQueryableExecuter.ToListAsync(query); var addresslist = new PagedResultDto <AddressDto>( totalCount, entities.Select(MapToGetListOutputDto).ToList() ); var userDictionary = new Dictionary <Guid, MallUserDto>(); foreach (var addressDto in addresslist.Items) { if (addressDto.CreatorId.HasValue) { if (!userDictionary.ContainsKey(addressDto.CreatorId.Value)) { var creatorUser = await UserLookupService.FindByIdAsync(addressDto.CreatorId.Value); if (creatorUser != null) { userDictionary[creatorUser.Id] = ObjectMapper.Map <MallUser, MallUserDto>(creatorUser); } } if (userDictionary.ContainsKey(addressDto.CreatorId.Value)) { addressDto.MallUser = userDictionary[(Guid)addressDto.CreatorId]; } } } return(addresslist); }
public Task <List <EntityDynamicParameter> > GetAllAsync() { return(_asyncQueryableExecuter.ToListAsync( _entityDynamicParameterRepository.GetAllIncluding(false, e => e.DynamicParameter) .OrderBy(edp => edp.EntityFullName).ThenBy(edp => edp.DynamicParameterId))); }
public virtual Task <List <DynamicPropertyValue> > GetAllValuesOfDynamicPropertyAsync(int dynamicPropertyId) { return(_asyncQueryableExecuter.ToListAsync(_dynamicPropertyValuesRepository.GetAll() .Where(propertyValue => propertyValue.DynamicPropertyId == dynamicPropertyId))); }
public Task <List <DynamicEntityProperty> > GetAllAsync() { return(_asyncQueryableExecuter.ToListAsync( _dynamicEntityPropertyRepository.GetAllIncluding(e => e.DynamicProperty) .OrderBy(edp => edp.EntityFullName).ThenBy(edp => edp.DynamicPropertyId))); }