コード例 #1
0
 public GetTrackListQueryHandler(ICatalogRepository catalogRepository, ITrackFilter trackFilter, IMapper mapper, ILogger <GetTrackListQueryHandler> logger)
 {
     _catalogRepository = catalogRepository ?? throw new ArgumentNullException(nameof(catalogRepository));
     _trackFilter       = trackFilter ?? throw new ArgumentNullException(nameof(trackFilter));
     _mapper            = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #2
0
        public async Task <IPagedCollection <Track> > GetTracks(ITrackFilter filter, int pageNumber, int pageSize, CancellationToken cancellationToken)
        {
            var linqTrackFilter = filter as LinqTrackFilter;

            if (linqTrackFilter is null)
            {
                throw new ArgumentException("Sql catalog repository expects a linq track filter");
            }

            return(await _catalogDbContext
                   .Tracks
                   .TagWithQueryName(nameof(GetTracks))
                   .AsNoTracking()
                   .Where(linqTrackFilter.Filter)
                   .Include(track => track.Genre)
                   .Include(track => track.Album !.Artist)
                   .Include(track => track.MediaType)
                   .ToPagedCollectionAsync(pageNumber, pageSize, cancellationToken));
        }
コード例 #3
0
        public async Task <IPagedCollection <TrackDetail> > Handle(GetTrackListQuery request, CancellationToken cancellationToken)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            _logger.LogInformation("Handle {QueryType} for tracks like {TrackName} with page number {PageNumber} and page size {PageSize}", nameof(GetTrackListQuery), request.Name, request.PageNumber, request.PageSize);
            ITrackFilter filter = _trackFilter
                                  .WhereNameLike(request.Name)
                                  .WhereAlbumLike(request.Album)
                                  .WhereArtistLike(request.Artist)
                                  .WhereComposerLike(request.Composer)
                                  .WhereGenreLike(request.Genre)
                                  .WhereMediaTypeLike(request.MediaType)
                                  .WherePlaylistIdEquals(request.PlaylistId)
                                  .WherePrice(request.PriceFrom, request.PriceTo);

            IPagedCollection <Track> tracksDomain = await _catalogRepository.GetTracks(filter, request.PageNumber, request.PageSize, cancellationToken);

            var tracks = _mapper.Map <IReadOnlyList <TrackDetail> >(tracksDomain);

            return(new PagedCollection <TrackDetail>(tracks, tracksDomain.ItemCount, tracksDomain.CurrentPageNumber, tracksDomain.PageSize));
        }
コード例 #4
0
 public Atm CreateAtm(ITrackFilter trackFilter)
 {
     return(new Atm(trackFilter));
 }
コード例 #5
0
ファイル: ATM.cs プロジェクト: SWT19GRP1/SWT1ATM
 public Atm(ITrackFilter track)
 {
     AirCrafts = new List <IVehicle>();
     track.AirTrackToMonitorEvent      += OnTrackDataRecieved;
     track.AirTrackOutSideMonitorEvent += OnRemoveAirPlainRecievedEvent;
 }