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 ReestrEditViewModel(ICustomerDataService customerDataService, ModalNavigationStore modalNavigationStore) { _customerDataService = customerDataService; _modalNavigationStore = modalNavigationStore; SubmitCommand = new DelegateCommand(ExecuteSubmitCommand); CancelCommand = new DelegateCommand(() => modalNavigationStore.Close()); Task.Run(Initialize); }
public void CloseDialogSuccess() { Reestr.Customer = SelectedCustomer; Reestr.CustomerId = SelectedCustomer.Id; var model = new ModelDialogParameter <Reestr> { IsSuccess = true, Value = Reestr }; DialogClosed?.Invoke(model); _modalNavigationStore.Close(); }
private async void ExecuteSubmitCommand() { ReestrSetting.RecipeId = SelectedRecipe.Id; ReestrSetting.CurrentRecipe = SelectedRecipe; ReestrSetting.Customer = SelectedCustomer; ReestrSetting.CustomerId = SelectedCustomer.Id; if (ReestrSetting.Id == 0) { await _reestrSettingDataService.CreateReestrSetting(ReestrSetting); } else { await _reestrSettingDataService.UpdateReestrSetting(ReestrSetting); } var result = new ModelDialogParameter <ReestrSetting> { IsSuccess = true, Value = (ReestrSetting)ReestrSetting.Clone() }; _modalNavigationStore.Close(); DialogClosed?.Invoke(result); }
public void Navigate() { _navigationStore.Close(); }