예제 #1
0
        private async void EditPurchase()
        {
            if (ListViewPurchases.SelectedItem is IngredientPurchase purchase)
            {
                // prepare and show dialog
                var dialog = new ContentDialogIngredientPurchase("Edit Ingredient Purchase", purchase);
                var result = await dialog.ShowAsync();


                // while Add New Category button is pressed
                while (dialog.Tag is string && (string)(dialog.Tag) == "Add New Provider")
                {
                    await AddProvier();                    // show add category dialog

                    dialog.Tag = null;                     // remember to reset Tag property
                    result     = await dialog.ShowAsync(); // show ingredient dialog again
                }

                // if ok button is pressed
                if (result == ContentDialogResult.Primary)
                {
                    MainModelView.Current.UpdateIngredientPurchase(purchase);

                    await UpdateAverageCosts();
                }
            }
        }
예제 #2
0
        private async void AddPurchase()
        {
            // prepare and show dialog
            IngredientPurchase purchase = new IngredientPurchase();

            purchase.Ingredient   = this.ingredient;
            purchase.IngredientID = this.ingredient.ID;
            purchase.Date         = DateTime.Today;
            var dialog = new ContentDialogIngredientPurchase("Add Ingredient Purchase", purchase);
            var result = await dialog.ShowAsync();

            // while Add New Category button is pressed
            while (dialog.Tag is string && (string)(dialog.Tag) == "Add New Provider")
            {
                await AddProvier();                    // show add category dialog

                dialog.Tag = null;                     // remember to reset Tag property
                result     = await dialog.ShowAsync(); // show ingredient dialog again
            }

            // if ok button is pressed
            if (result == ContentDialogResult.Primary)
            {
                purchases.Add(purchase);

                MainModelView.Current.AddIngredientPurchase(purchase);

                await UpdateAverageCosts();
            }
        }