public AddIngredientPageViewModel( IIngredientsRepository ingredientsRepository, INavigationService navigationService, IUserInteraction userInteraction, ICrossMediaService crossMediaService) : base(navigationService, userInteraction, crossMediaService) { DrinkIngredientViewModel = new DrinkIngredientViewModel(new Ingredient()); AcceptCommand = ReactiveCommand.CreateFromTask(async _ => { if (!await IsInputValidAsync()) { return; } DrinkIngredientViewModel.Name = IngredientName; DrinkIngredientViewModel.ByteImage = IngredientImage; DrinkIngredientViewModel.BottleIndex = BottleIndex; DrinkIngredientViewModel.UpdateIngredientModel(); await ingredientsRepository.InsertAsync(DrinkIngredientViewModel.Ingredient); await navigationService.PopAsync(); }); }
public AddDrinkRecipePageViewModel( IUserInteraction userInteraction, INavigationService navigationService, IDrinkRecipeBuilder drinkRecipeBuilder, IDrinkRecipesRepository drinkRecipesRepository, ICrossMediaService crossMediaService, ISelectionHost <DrinkIngredientViewModel> selectionHost) : base(userInteraction, navigationService, drinkRecipeBuilder, crossMediaService, selectionHost) { _userInteraction = userInteraction; _drinkRecipeBuilder = drinkRecipeBuilder; _drinkRecipesRepository = drinkRecipesRepository; }
public AddmilkDigitalIDPageViewModel(INavigation navigation = null, HOPage root = null) : base(navigation) { _crossMediaService = DependencyService.Get <ICrossMediaService>(); Root = root; #if DEBUG FirstStep = new FirstStepModel { FirstName = "First Name", MiddleName = "Middle Name", LastName = "Last Name", NickName = "Nick Name", DateOfBirth = new DateTime(1990, 1, 1), Gender = "Male", Height = "5", Weight = "50" }; #endif }
public EditDrinkRecipePageViewModel( IUserInteraction userInteraction, IDrinkRecipeBuilder drinkRecipeBuilder, INavigationService navigationService, IDrinkRecipesRepository drinkRecipesRepository, ICrossMediaService crossMediaService, ISelectionHost <DrinkIngredientViewModel> selectionHost, DrinkRecipeViewModel drinkRecipeViewModel) : base(userInteraction, navigationService, drinkRecipeBuilder, crossMediaService, selectionHost) { _userInteraction = userInteraction; _drinkRecipeBuilder = drinkRecipeBuilder; _drinkRecipesRepository = drinkRecipesRepository; _drinkIngredient = drinkRecipeViewModel; DrinkName = drinkRecipeViewModel.Name; ByteImage = drinkRecipeViewModel.ByteImage; DrinkIngredients.AddRange(drinkRecipeViewModel.IngredientViewModels); }
protected ConfigureDrinkRecipePageViewModelBase( IUserInteraction userInteraction, INavigationService navigationService, IDrinkRecipeBuilder drinkRecipeBuilder, ICrossMediaService crossMediaService, ISelectionHost <DrinkIngredientViewModel> selectionHost) { _userInteraction = userInteraction; _navigationService = navigationService; SelectionHost = selectionHost; var addIngredientCanExecute = this.WhenAnyValue(vm => vm.DrinkIngredients.Count, i => i < 6); addIngredientCanExecute .Where(canExecute => !canExecute) .SubscribeAsync(async() => await _userInteraction.DisplayAlertAsync("Info", "Cannot have more then 6 ingredients", "Ok")); var alreadySelectedParameter = new TypedParameter(typeof(IEnumerable <DrinkIngredientViewModel>), DrinkIngredients); AddIngredientCommand = ReactiveCommand.CreateFromTask(async _ => await _navigationService.PushAsync <SelectIngredientsPageViewModel>(alreadySelectedParameter), addIngredientCanExecute); AbortCommand = ReactiveCommand.CreateFromTask(async _ => await _navigationService.PopAsync()); var completedCommandCanExecute = DrinkIngredients.CountChanged .Select(count => count != 0); completedCommandCanExecute .Where(hasIngredients => !hasIngredients) .Skip(1) .Select(async _ => await _userInteraction.DisplayAlertAsync("Warning", "Add ingredients or abort the process!", "ok")) .Subscribe(_ => {}, ex => throw ex); CompleteCommand = ReactiveCommand.CreateFromTask(async _ => { if (!IsDrinkValid(out StringBuilder msgBuilder)) { await userInteraction.DisplayAlertAsync("Error", msgBuilder.ToString(), "Ok"); return; } var ingredients = DrinkIngredients .Select(ivm => ivm.UpdateDrinkIngredientModel()) .ToList(); await CompletedTemplateMethod(drinkRecipeBuilder, ingredients); await navigationService.PopAsync(); }, completedCommandCanExecute); CompleteCommand.ThrownExceptions.Subscribe(exception => throw exception); ByteImageTapRecognizerCommand = ReactiveCommand.CreateFromTask(async _ => { var photo = await crossMediaService.GetPhotoAsync(); if (photo != null) { ByteImage = photo; } }); }