public async Task <long> Handle(CreateDataSourceCommand request, CancellationToken cancellationToken) { var user = await _context.Users.FindAsync(new object[] { request.UserId }, cancellationToken : cancellationToken); if (user == null) { throw new NotFoundException(nameof(User), request.UserId); } var entity = new PlaylistDataSource { Name = request.Name, State = request.State ? Domain.Entities.Core.OnlineState.Enabled : Domain.Entities.Core.OnlineState.Disabled, User = user, PlaylistDataSourceFormat = request.PlaylistDataSourceFormat }; _context.PlaylistDataSources.Add(entity); await _context.SaveChangesAsync(cancellationToken); await _mediator.Publish(new DataSourceCreated { DataSourceId = entity.Id }, cancellationToken); return(entity.Id); }
public IDataSourceReader Create(PlaylistDataSource playlistDataSource) { if (playlistDataSource is M3uPlaylistDataSource uPlaylistDataSource) { return(new M3UDataSourceReader(uPlaylistDataSource)); } else if (playlistDataSource is XtreamPlaylistDataSource xtreamDataSource) { return(new XtreamDataSourceReader(xtreamDataSource, _xtreamClient)); } return(null); }
public static DatasourceLookupViewModel Create(PlaylistDataSource ds) { return(Projection.Compile().Invoke(ds)); }