public RecipesViewModel()
        {
            Title            = "Recipes List";
            Items            = new ObservableCollection <Recipe>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewRecipePage, Recipe>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Recipe;

                Items.Add(newItem);

                // Testing
                var ingredient = new Ingredient()
                {
                    Name         = "Eggs",
                    Quantity     = 1,
                    QuantityType = Helpers.HelperEnums.QuantityType.Boxes
                };

                bool success = await IngredientDataStore.AddAsync(ingredient);
                var list     = await IngredientDataStore.GetAllAsync();

                foreach (var itm in list)
                {
                }

                //await RecipeDataStore.AddAsync(newItem);
            });
        }
示例#2
0
 async void LoadList()
 {
     _users            = (await UserDataStore.GetItemsAsync(true)).Where(c => !c.Name.Equals("Storage")).ToList();
     _ingredientCounts = (await IngredientCountDataStore.GetItemsAsync(true))
                         .OrderBy(c => DateTime.Parse(c.Date)).ToList();
     _ingredients  = (await IngredientDataStore.GetItemsAsync(true)).ToList();
     _records      = (await RecordDataStore.GetItemsAsync(true)).ToList();
     _avtomats     = (await AvtomatDataStore.GetItemsAsync(true)).ToList();
     _userAvtomats = (await UserAvtomatDataStore.GetItemsAsync(true)).ToList();
 }
示例#3
0
        private async void LoadData()
        {
            _ingredientCounts = (await IngredientCountDataStore.GetItemsAsync(true)).ToList();
            _ingredients      = (await IngredientDataStore.GetItemsAsync(true)).ToList();
            _records          = (await RecordDataStore.GetItemsAsync(true)).ToList();
            _users            = (await UserDataStore.GetItemsAsync(true)).ToList();

            var strgusr = _users.FirstOrDefault(c => c.Name.Equals("Storage"));

            if (strgusr == null)
            {
                _storageUser = new User()
                {
                    Id = Guid.NewGuid().ToString(), Name = "Storage"
                };
                await UserDataStore.AddItemAsync(_storageUser);
            }
            else
            {
                _storageUser = strgusr;
            }
        }
示例#4
0
 async void LoadIngredients()
 {
     _ingredients = (await IngredientDataStore.GetItemsAsync(true)).ToList();
 }