Ejemplo n.º 1
0
        /// <summary>
        /// hydrate the user value
        /// create retryManager
        /// hydrade listFoodCategoryAndSubs from xml
        /// hydrate ObservableListFoods
        /// hydrate ObservableListFoods
        /// create Subviews
        /// </summary>
        /// <param name="mUser"></param>
        public MainWindowViewModel(User mUser)
        {
            User defaultUser = new User()//todo delete en production
            {
                Login    = "******",
                Password = "******",
                Token    = "35476D40AD60D59A21A600B450C084DE"
            };

            User = mUser ?? defaultUser;

            retryManager            = new RetryManager(userServiceClient, foodManagerServiceClient);
            ListFoodCategoryAndSubs = FoodCategoriesAndSubsLoader.GetCategoriesList(
                XElement.Load(@"C:\Users\cleme\source\repos\MyFoodStock\Client\Ressources\XML\Categories.xml"));

            ObservableListFoods   = new ObservableCollection <Food>(retryManager.RetryGetFoodList(User));
            ObservableListRecipes = new ObservableCollection <Recipe>(retryManager.RetryGetRecipesList(User));
            SubViewDictionary     = new Dictionary <string, MainWindowSubViewModelBase>()
            {
                {
                    "MyFoodstock", new MyFoodstockSubViewModel(ObservableListFoods, ListFoodCategoryAndSubs)
                    {
                        RemoveFoodCommand = DeleteFoodCommand,
                        UpdateFoodCommand = UpdateFoodCommand
                    }
                },
                {
                    "Recipes", new RecipesSubViewModel()
                    {
                        ListRecipes         = ObservableListRecipes,
                        SelectedRecipe      = ObservableListRecipes.First(),
                        OpenRecipeCommand   = OpenRecipeCommand,
                        DeleteRecipeCommand = DeleteRecipeCommand,
                        UpdateRecipeCommand = UpdateRecipeCommand
                    }
                }
            };
        }