private SelectionViewModel <Season> CreateSeasonSelectionViewModel() { return(_viewModelRepository.CreateViewModel <SelectionViewModel <Season> >(this, (vm) => vm.FillSelectionList(new[] { Tuple.Create("All Seasons", Season.All), Tuple.Create("Summer", Season.Summer), Tuple.Create("Winter", Season.Winter), Tuple.Create("Spring", Season.Spring), Tuple.Create("Autumn", Season.Autumn) }))); }
private async Task RetrieveIngredients() { Debug.WriteLine("RetrieveIngredients"); var ingredients = await _sessionStateManager.GetIngredients(RecipeRegistration); var ingredientViewModel = new List <IViewModel>(); foreach (var ingredient in ingredients) { Debug.WriteLine("Creating ingredient viewmodel for " + ingredient.IngredientName); var cvm = _viewModelRepository.CreateViewModel <IngredientViewModel>(this, (cv) => cv.Ingredient = ingredient); ingredientViewModel.Add(cvm); } IngredientViewModelManager.Update(ingredientViewModel); }
public void InitializeMenu(IEnumerable <INavigation> navigationItems, ISessionState sessionState = null) { List <IViewModel> viewModels = new List <IViewModel>(); Debug.WriteLine("NavMenuViewModel.InitializeMenu"); viewModels.Add(_viewModelRepository.CreateViewModel <NavMenuItemViewModel>(this, (ni) => ni.Initialize("Home", true))); if (navigationItems != null) { foreach (var navigationItem in navigationItems) { viewModels.Add(_viewModelRepository.CreateViewModel <NavMenuItemViewModel>(this, (ni) => ni.Initialize(navigationItem))); } } MenuItemCollectionManager.Update(viewModels); }
private SelectionViewModel <IngredientType> CreateIngredientTypeSelectionViewModel() { return(_viewModelRepository.CreateViewModel <SelectionViewModel <IngredientType> >(this, (vm) => vm.FillSelectionList(new[] { Tuple.Create("Unknown", IngredientType.Unknown), Tuple.Create("Fresh", IngredientType.Fresh), Tuple.Create("Stock", IngredientType.Stock) }))); }
public void InitializeComponents(IEnumerable <RecipeRegistration> recipes) { if (recipes == null) { throw new ArgumentNullException(nameof(recipes)); } List <IViewModel> recipeViewModels = new List <IViewModel>(); foreach (var item in recipes) { var cvm = _viewModelRepository.CreateViewModel <RecipeViewModel>(this, (cv) => cv.RecipeRegistration = item); recipeViewModels.Add(cvm); } RecipeViewModelManager.Update(recipeViewModels); }
public override async Task HandleChanges(object sender, object changes) { if (changes is ISessionState sessionState) { var navigationItems = NavigationItems; // We'd usually do some proper login checks here! if (sessionState.IsLoggedIn) { navigationItems.Add(new Navigation(() => ContentViewModelManager.Update(_viewModelRepository.CreateViewModel <RegisterRecipeViewModel>(this)), "Register Recipe")); navigationItems.Add(new Navigation(() => ContentViewModelManager.Update(_viewModelRepository.CreateViewModel <RecipeSummaryViewModel>(this, m => m.InitializeComponents(sessionState.Recipes))), "Your Recipes")); InformationViewModelManager.Update(_viewModelRepository.CreateViewModel <InformationViewModel>(this, (vm) => vm.OrganisationName = sessionState.Organisation.OrganisationName)); } else { InformationViewModelManager.Update(_viewModelRepository.CreateViewModel <InformationViewModel>(this, (vm) => vm.OrganisationName = string.Empty)); } Debug.WriteLine("NavigationMenuModel.UpdateMenu state : " + sessionState.AccessKey); await Task.Run(() => NavigationMenuModelManager.Update(_viewModelRepository.CreateViewModel <NavMenuViewModel>(this, (nm) => nm.InitializeMenu(navigationItems, sessionState)))); Debug.WriteLine("No SessionStateManager_SessionUpdated state ends"); } }