예제 #1
0
        public async Task <PageDto <StationDto> > GetPageAsync(int pageSize, int pageNumber)
        {
            var page  = new PageDto <StationDto>(pageSize, pageNumber);
            var items = await _unitOfWork.Stations.GetPageAsync(pageSize, pageNumber);

            page.SetData(items.Item2, items.Item1.Select(i => StationDto.FromDomain(i)).ToList());
            return(page);
        }
예제 #2
0
        public async Task <StationDto> GetAsync(int id)
        {
            var dto = await _cacheStore.StoreAndGetAsync(GetCacheKey(id), async() =>
            {
                var item = await Get(id);
                return(StationDto.FromDomain(item));
            });

            return(dto);
        }
예제 #3
0
        public async Task <IEnumerable <StationDto> > GetByOrganizationAsync(int id)
        {
            var items = await _unitOfWork.Stations.GetAsync(s => s.OrganizationId == id);

            IEnumerable <StationDto> ConvertToDtoList(IEnumerable <Station> list)
            {
                foreach (var item in list)
                {
                    yield return(StationDto.FromDomain(item));
                }
            }

            return(ConvertToDtoList(items));
        }
예제 #4
0
        public async Task <IEnumerable <StationDto> > GetNeighboursByStation(int id)
        {
            var items = await _unitOfWork.Stations.GetAsync(s =>
                                                            s.PreStationId == id || s.PostStationId == id);

            IEnumerable <StationDto> ConvertToDtoList(IEnumerable <Station> list)
            {
                foreach (var item in list)
                {
                    yield return(StationDto.FromDomain(item));
                }
            }

            return(ConvertToDtoList(items));
        }