public FlightViewModel(FlightSummary summary, IFlightAcademyClient flightAcademyClient, ContentMatcher matcher)
        {
            this.summary = summary;
            this.matcher = matcher;

            LoadItems = ReactiveCommand.CreateFromObservable(() => Load().ToList());
            LoadItems.ThrownExceptions.Subscribe(x => { });
            items = LoadItems.ToProperty(this, x => x.Items);
        }
Esempio n. 2
0
        public FlightViewModel(FlightSummary summary, IMediaStore matcher, IViewModelFactory viewModelFactory)
        {
            this.summary = summary;

            LoadItems = ReactiveCommand.CreateFromObservable(() => matcher
                                                             .RecordingsBetween(this.summary.Date.ToInterval(this.summary.TotalRunTime))
                                                             .SelectMany(file => viewModelFactory.CreateFlightContentViewModel(summary.Id, file)).ToList());
            items  = LoadItems.ToProperty(this, x => x.Items);
            isBusy = LoadItems.IsExecuting.ToProperty(this, x => x.IsBusy);
            Play   = ReactiveCommand.CreateFromObservable((FlightContentViewModel e) => e.PlayCommand.Execute());
        }
Esempio n. 3
0
        public CatalogItemListViewModel(
            string categoryId,
            ICatalogItemRepoFactory itemRepoFactory = null,
            IViewStackService viewStackService      = null)
        {
            itemRepoFactory  = itemRepoFactory ?? Locator.Current.GetService <ICatalogItemRepoFactory>();
            viewStackService = viewStackService ?? Locator.Current.GetService <IViewStackService>();

            var itemRepo = itemRepoFactory.Create(categoryId);

            LoadItems = ReactiveCommand.CreateFromObservable(
                () =>
            {
                return(itemRepo
                       .GetItems()
                       .SelectMany(x => x)
                       .Select(x => new CatalogItemCellViewModel(x, itemRepo))
                       .ToList()
                       .Select(x => x as IReadOnlyList <ICatalogItemCellViewModel>));
            });

            _items = LoadItems.ToProperty(this, x => x.Items);

            var firebaseStorageService = Locator.Current.GetService <GameCtor.FirebaseStorage.DotNet.IFirebaseStorageService>();

            DownloadImages = ReactiveCommand.CreateFromObservable(
                () =>
            {
                return(Items
                       .ToObservable()
                       .SelectMany(
                           itemCell =>
                {
                    return firebaseStorageService
                    .GetDownloadUrl("catalogPhotos/" + itemCell.Id + ".jpg")
                    .Catch <string, Exception>(ex => Observable.Return <string>(null))
                    .Where(x => x != null)
                    .Do(imageUrl => itemCell.ImageUrl = imageUrl)
                    .Select(_ => itemCell);
                })
                       .SelectMany(
                           itemCell =>
                {
                    return itemRepo
                    .Upsert(itemCell.Model);
                }));
            });
        }