public InventoryService(IInventoryDataService dataService, IUserService userService, ITransactionDataService transactionDataService, ITransactionSubTypeService transactionSubTypeService) { this._dataService = dataService; this._userService = userService; this._transactionDataService = transactionDataService; this._transactionSubTypeService = transactionSubTypeService; }
public InfiniteScrollViewModel(IInventoryDataService inventoryDataService) { _inventoryDataService = inventoryDataService; _pagingSubject = new BehaviorSubject <IPageRequest>(new PageRequest(0, pageSize)); Func <InventoryItemViewModel, bool> Search(string searchTerm) => viewModel => { if (string.IsNullOrEmpty(searchTerm)) { return(true); } var lower = searchTerm.ToLower(); return(viewModel.Brand.ToLower().Contains(lower) || (viewModel.Coffee?.ToLower().Contains(lower) ?? false)); }; var searchChanged = this.WhenAnyValue(x => x.SearchText) .Throttle(TimeSpan.FromMilliseconds(800), RxApp.TaskpoolScheduler) .DistinctUntilChanged() .Select(Search); _inventoryDataService .ChangeSet .Transform(x => new InventoryItemViewModel { Id = x.Id, Brand = x.BrandName, Coffee = x.CoffeeName, Roast = x.Roast, Packaging = x.Packaging }) .AutoRefresh(x => x.Id) .DeferUntilLoaded() .Filter(searchChanged) .Sort(SortExpressionComparer <InventoryItemViewModel> .Descending(x => x.Roast)) .Page(_pagingSubject.AsObservable()) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _items) .DisposeMany() .Subscribe() .DisposeWith(Garbage); this.WhenAnyObservable(x => x.Refresh.IsExecuting) .StartWith(false) .DistinctUntilChanged() .ToProperty(this, nameof(IsRefreshing), out _isRefreshing, deferSubscription: true) .DisposeWith(Garbage); this.WhenAnyObservable(x => x.Load.IsExecuting) .ToProperty(this, nameof(IsLoading), out _isLoading, deferSubscription: true) .DisposeWith(Garbage); Refresh = ReactiveCommand.CreateFromObservable <EventArgs, Unit>(ExecuteRefresh); Load = ReactiveCommand.CreateFromObservable <int, Unit>(ExecuteLoad); _pagingSubject.DisposeWith(Garbage); }
public InfiniteCollectionViewModel(IInventoryDataService inventoryDataService) { _inventoryDataService = inventoryDataService; _pagingSubject = new BehaviorSubject <IPageRequest>(new PageRequest(0, _pageSize)); _inventoryDataService .ChangeSet .Transform(x => new InfiniteItemViewModel(x)) .Sort(SortExpressionComparer <InfiniteItemViewModel> .Ascending(x => x.Id)) .Page(_pagingSubject.AsObservable()) .Bind(out _inventory) .DisposeMany() .Subscribe() .DisposeWith(ViewModelSubscriptions); Load = ReactiveCommand.CreateFromObservable(ExecuteLoad); }