public ReestrSettingViewModel( ModalNavigationStore modalNavigationStore, IBarrelStorageDataService barrelStorageDataService, IReestrSettingDataService reestrSettingDataService, IRecipeDataService recipeDataService, ICustomerDataService customerDataService) { _modalNavigationStore = modalNavigationStore; _barrelStorageDataService = barrelStorageDataService; _reestrSettingDataService = reestrSettingDataService; _recipeDataService = recipeDataService; _customerDataService = customerDataService; this.WhenAnyValue(x => x.Password) .Throttle(TimeSpan.FromSeconds(1)) .Where(x => !string.IsNullOrWhiteSpace(x)) .ObserveOnDispatcher() .Subscribe(PasswordChecker); this.WhenAnyValue(x => x.SelectedRecipe) .Skip(1) .SelectMany(async(x) => await _barrelStorageDataService.GetLastBarrelNumber(x)) .ObserveOnDispatcher() .Subscribe(number => ReestrSetting.InitialBarrelNumber = number + 1); Task.Run(Initialize); SubmitCommand = new DelegateCommand(ExecuteSubmitCommand); CancelCommand = new DelegateCommand(() => modalNavigationStore.Close()); }
public StatusViewModel(IBarrelStorageDataService barrelStorageDataService, IReestrDataService reestrDataService) { _barrelStorageDataService = barrelStorageDataService; _reestrDataService = reestrDataService; RecipeReminder = new RecipeReminder(); _currentRecipe = new Recipe(); MessageBus.Current.Listen <ReestredAddedEvent>() .SelectMany(x => UpdateStatus(x.Reestr)) .Subscribe(); MessageBus.Current.Listen <Recipe>() .Where(x => x.Id != _currentRecipe.Id) .SelectMany(CalculateReminder) .Subscribe(); }
public BarrelViewModel(IRecipeDataService recipeDataService, IBarrelStorageDataService barrelStorageDataService) { var canExecute = this .WhenAnyValue(x => x.SelectedRecipe, x => x.BarrelStorage.TotalWeight, (selectedReice, total) => selectedReice != null && total > 0); this.WhenAnyValue(x => x.SelectedRecipeForFilter) .Where(x => x != null) .Select(x => x) .Subscribe(FilterCollection); BarrelStorage.ProductionDate = DateTime.Now; _recipeDataService = recipeDataService; _barrelStorageDataService = barrelStorageDataService; CreateRecipe = ReactiveCommand.CreateFromTask(ExecuteCreateBarrelStorage, canExecute); CreateRecipe.Subscribe(x => AddBarrelStorage(x)); Task.Run(Initialize); }