public async Task <ServiceResultList <TGetAllDto> > GetAllAsync()
        {
            _logger?.LogInformation($"Método: { nameof(GetAllAsync) }() Retorno: IEnumerable<{ typeof(TGetAllDto).Name }>");

            var entities = await _readRepository.GetAllAsync().AsyncEnumerableToEnumerable();

            return(_serviceResultFactory.Create(entities.Select(entity => _mapper.Map <TGetAllDto>(entity))));
        }
        public async Task FetchAndStore()
        {
            Expression <Func <HotTourView, HotTourViewDto> > projection = hotTourView => new HotTourViewDto
            {
                Name                = hotTourView.Name,
                PriceAmount         = hotTourView.PriceAmount,
                DepartureLocationId = hotTourView.DepartureLocationId,
                DepartureDate       = hotTourView.DepartureDate
            };

            var projectedQueryParams = new ProjectedQueryParams <HotTourView, HotTourViewDto>
            {
                Projection = projection
            };

            var providerQuery = new HotToursProviderQuery
            {
                DurationFrom = 1,
                DurationTo   = 21,
                PriceFrom    = 1,
                PriceTo      = 200000,
                Count        = 1000
            };

            var newTours = await _toursProvider.GetHotToursAsync(providerQuery);

            var existingTours = await _repository.GetAllAsync(projectedQueryParams);

            var uniqueTours = newTours
                              .Where(n => existingTours.All(e =>
                                                            e.Name != n.Info.Name ||
                                                            e.Name == n.Info.Name && e.PriceAmount != n.Price.Amount ||
                                                            e.Name == n.Info.Name && e.DepartureLocationId != n.DepartureLocation.Id ||
                                                            e.Name == n.Info.Name && e.DepartureDate != n.DepartureDate))
                              .ToList();

            _unitOfWork.HotToursWriteRepository.SaveRange(uniqueTours);

            var deleteResult = await _cache.CleanAsync();

            if (deleteResult.IsFailure)
            {
                _logger.LogCritical(deleteResult.Error);
            }

            await _unitOfWork.CommitAsync();

            _logger.LogInformation($"Fetched {newTours.Count} and stored {uniqueTours.Count} tours.");
        }
Пример #3
0
        public async Task <IActionResult> GetNewSaleData()
        {
            var storeId = GetStoreId();

            var users = (await _userRepository.FindAsync(x => (x.MainStoreId == storeId || x.StoreIds.Contains(storeId)) && (x.Role == "seller" || x.Role == "storemanager"))).Select(x => new { x.Id, x.Firstname });

            var companies = (await _companyRepository.FindAsync(x => x.StoreId == storeId)).Select(x => new { x.Id, x.Name });

            var products = await _productRepository.GetAllAsync();

            var hardwares     = products.Where(x => x.Type == "Hårdvara").Select(x => new { x.Id, x.Title });
            var subscriptions = products.Where(x => x.Type == "Abonnemang").Select(x => new { x.Id, x.Title });
            var extras        = products.Where(x => x.Type == "Tilläggstjänst").Select(x => new { x.Id, x.Title });

            var data = new { sellers = users, companies, hardwares, subscriptions, extras };

            return(Ok(data));
        }
 public async Task <IEnumerable <T> > GetAllAsync()
 {
     return(await _repository.GetAllAsync());
 }
 public async Task <Character[]> GetAllCharacters()
 => await _characterRepository.GetAllAsync();
        public async Task <IActionResult> Products()
        {
            var products = await _readRepository.GetAllAsync();

            return(Ok(products));
        }
 public Task <Episode[]> GetAllEpisodes()
 => _episodeRepository.GetAllAsync();
        public async Task <IActionResult> Get()
        {
            var stores = await _readRepository.GetAllAsync();

            return(Ok(stores));
        }
Пример #9
0
 public async Task <IEnumerable <SubjectReadModel> > Handle(GetSubjectsQuery request, CancellationToken cancellationToken)
 {
     return(await _readRepository.GetAllAsync());
 }