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 <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 SeedAsync(DataSeedContext context) { if (await _queryableExecuter.CountAsync(_bookRepository) > 0) { return; } await _bookRepository.InsertAsync( new Book { Name = "Pet Sematary", Price = 42, PublishDate = new DateTime(1995, 11, 15), Type = BookType.Horror } ); }
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 async Task AddBookmarkAsync(Guid userId, Guid articleId) { var query = _bookmarksRepository.Where(d => d.ArticleId == articleId && d.UserId == userId); var count = await _asyncQueryExecutor.CountAsync(query); if (count > 0) { return; } await _bookmarksRepository.InsertAsync(new UserArticleBookmark { UserId = userId, ArticleId = articleId }); await _uowManager.Current.SaveChangesAsync(); }
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 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 <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 SeedAsync(DataSeedContext context) { if (await _queryableExecuter.CountAsync(_enterpriseRepository) < 1) { for (int i = 1; i < 200; i++) { await _enterpriseRepository.InsertAsync( new Enterprises.Enterprise(_guidGenerator.Create(), $"新密第{i}耐火厂", $"新密市嵩山大道{i}号", "13800138000", $"测试数据{i}")); } } if (await _queryableExecuter.CountAsync(_orderStatusRepository) < 1) { await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "新建", null)); await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "已排产", null)); await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "生产中", null)); await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "生产完", null)); await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "待发货", null)); await _orderStatusRepository.InsertAsync(new Orders.OrderStatus(_guidGenerator.Create(), "撤销", null)); } if (await _queryableExecuter.CountAsync(_equipmentInspectionResultRepository) < 1) { await _equipmentInspectionResultRepository.InsertAsync(new Equipments.EquipmentInspectionResult(_guidGenerator.Create(), "正常", null)); await _equipmentInspectionResultRepository.InsertAsync(new Equipments.EquipmentInspectionResult(_guidGenerator.Create(), "异常", null)); await _equipmentInspectionResultRepository.InsertAsync(new Equipments.EquipmentInspectionResult(_guidGenerator.Create(), "异常不影响生产", null)); await _equipmentInspectionResultRepository.InsertAsync(new Equipments.EquipmentInspectionResult(_guidGenerator.Create(), "待检查", null)); } if (await _queryableExecuter.CountAsync(_equipmentMaintenanceResultRepository) < 1) { await _equipmentMaintenanceResultRepository.InsertAsync(new Equipments.EquipmentMaintenanceResult(_guidGenerator.Create(), "待维修", null)); await _equipmentMaintenanceResultRepository.InsertAsync(new Equipments.EquipmentMaintenanceResult(_guidGenerator.Create(), "维修完成待观察", null)); await _equipmentMaintenanceResultRepository.InsertAsync(new Equipments.EquipmentMaintenanceResult(_guidGenerator.Create(), "维修完成", null)); await _equipmentMaintenanceResultRepository.InsertAsync(new Equipments.EquipmentMaintenanceResult(_guidGenerator.Create(), "已正常", null)); } if (await _queryableExecuter.CountAsync(_supplierLevelRepository) < 1) { await _supplierLevelRepository.InsertAsync(new Suppliers.SupplierLevel(_guidGenerator.Create(), "一级", null)); await _supplierLevelRepository.InsertAsync(new Suppliers.SupplierLevel(_guidGenerator.Create(), "二级", null)); await _supplierLevelRepository.InsertAsync(new Suppliers.SupplierLevel(_guidGenerator.Create(), "三级", null)); await _supplierLevelRepository.InsertAsync(new Suppliers.SupplierLevel(_guidGenerator.Create(), "四级", null)); await _supplierLevelRepository.InsertAsync(new Suppliers.SupplierLevel(_guidGenerator.Create(), "五级", null)); } if (await _queryableExecuter.CountAsync(_unitRepository) < 1) { await _unitRepository.InsertAsync(new Public.Unit(_guidGenerator.Create(), "吨", null)); await _unitRepository.InsertAsync(new Public.Unit(_guidGenerator.Create(), "箱", null)); await _unitRepository.InsertAsync(new Public.Unit(_guidGenerator.Create(), "米", null)); await _unitRepository.InsertAsync(new Public.Unit(_guidGenerator.Create(), "千克", null)); } }