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); }
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); }
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)); }
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)); }