private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            TextBlockFullName.Text = AuthUser.Client.FullName;
            TextBlockMail.Text     = AuthUser.Client.Mail;
            TextBlocRole.Text      = AuthUser.Role;
            TextBlockCooks.Text    = AuthUser.Client.Cooks + " Cks";

            ServiceRecipe = new ServiceRecipe();

            if (AuthUser.RecipeCreator != null)
            {
                List <Recipe> recipes = ServiceRecipe.AllOf(AuthUser.RecipeCreator);
                if (recipes.Count > 0)
                {
                    ListViewRecipes.ItemsSource    = recipes;
                    StackPanelCreateNow.Visibility = Visibility.Collapsed;
                    GridRecipes.Visibility         = Visibility.Visible;
                }
            }

            ServiceOrder = new ServiceOrder();

            ListViewOrders.ItemsSource = ServiceOrder.AllOf(AuthUser.Client);

            if (ListViewOrders.Items.Count > 0)
            {
                StackPanelOrderNow.Visibility = Visibility.Collapsed;
                GridOrders.Visibility         = Visibility.Visible;
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ServiceRecipe = new ServiceRecipe();
            Recipes       = new ObservableCollection <Recipe>(ServiceRecipe.All(true));

            ListViewRecipes.ItemsSource = Recipes;
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ServiceRecipeCreator = new ServiceRecipeCreator();
            RecipeCreator recipeCreatorOfTheWeek = ServiceRecipeCreator.BestOfTheWeek();

            if (recipeCreatorOfTheWeek != null)
            {
                TextBlockRecipeCreatorOfTheWeek.Text         = recipeCreatorOfTheWeek.Client.FullName;
                TextBlockCountRecipesOfCreatorOfTheWeek.Text = $"{recipeCreatorOfTheWeek.RecipesSold} recipes sold last 7 days";
            }
            else
            {
                TextBlockCountRecipesOfCreatorOfTheWeek.Text = "No recipes sold last 7 days";
            }

            RecipeCreator recipeCreatorOfAllTime = ServiceRecipeCreator.BestOfAllTime();

            ServiceRecipe = new ServiceRecipe();

            if (recipeCreatorOfAllTime != null)
            {
                TextBlockRecipeCreatorOfAllTime.Text         = recipeCreatorOfAllTime.Client.FullName;
                TextBlockCountRecipesOfCreatorOfAllTime.Text = $"{recipeCreatorOfAllTime.RecipesSold} recipes sold";

                TextBlockTopOfBestCreatorTitle.Text         = "Top 5 recipes of: " + recipeCreatorOfAllTime.Client.FullName;
                ListViewTopRecipesOfBestCreator.ItemsSource = ServiceRecipe.AllOf(recipeCreatorOfAllTime, 5);
            }
            else
            {
                TextBlockCountRecipesOfCreatorOfTheWeek.Text = "No recipes sold";
            }

            ListViewTop5Recipes.ItemsSource = ServiceRecipe.Top(5);
        }
Пример #4
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ServiceRecipe serviceRecipe = new ServiceRecipe();

            serviceOrder = new ServiceOrder();

            recipesAvailable            = new ObservableCollection <Recipe>(serviceRecipe.All());
            ListViewRecipes.ItemsSource = recipesAvailable;

            order        = new Order();
            order.Client = AuthUser.Client;

            recipesInBucket = new ObservableCollection <Recipe>();
            ListViewRecipesInBucket.ItemsSource = recipesInBucket;
            order.Recipes = recipesInBucket.ToList();
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ServiceRecipeCreator = new ServiceRecipeCreator();
            List <RecipeCreator> recipeCreators = ServiceRecipeCreator.AllWithRecipes();

            ListViewRecipeCreators.ItemsSource = recipeCreators;
            TextBlockCountRecipeCreators.Text  = (recipeCreators.Count).ToString();

            ServiceProduct = new ServiceProduct();
            ListViewProductsToRestock.ItemsSource = ServiceProduct.AllForDemo();

            ServiceClient = new ServiceClient();
            TextBlockCountClients.Text = ((ServiceClient.All()).Count).ToString();

            ServiceRecipe = new ServiceRecipe();
            TextBlockCountRecipes.Text = ((ServiceRecipe.All()).Count).ToString();
        }
Пример #6
0
        private void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            string name        = TextBoxName.Text;
            string type        = ComboBoxType.Text;
            string priceString = TextBoxPrice.Text;
            int    price;
            string description = TextBoxDescription.Text;

            string[] fields = new string[] { name, type, priceString, description };

            string message = "";

            if (fields.Contains(""))
            {
                message += "- All fields are required." + Environment.NewLine;
            }

            if (!Int32.TryParse(priceString, out price))
            {
                message += "- Price must be a number." + Environment.NewLine;
            }

            if (price < 10 || price > 40)
            {
                message += "- Price must be between 10 and 40 cooks." + Environment.NewLine;
            }

            if (ProductsRequiredInRecipe.Count() == 0)
            {
                message += "- You must select at least one product." + Environment.NewLine;
            }

            if (message != "")
            {
                MessageBox.Show(message);
                return;
            }

            Recipe recipe = new Recipe();

            recipe.Name         = name;
            recipe.Type         = type;
            recipe.Price        = price;
            recipe.Description  = description;
            recipe.Remuneration = 2;

            recipe.RecipeCreator = new RecipeCreator();
            if (AuthUser.RecipeCreator != null)
            {
                recipe.RecipeCreator = AuthUser.RecipeCreator;
            }
            else
            {
                ServiceRecipeCreator = new ServiceRecipeCreator();
                recipe.RecipeCreator = ServiceRecipeCreator.Save(AuthUser.Client);
            }

            recipe.Products = ProductsRequiredInRecipe.ToList();

            ServiceRecipe = new ServiceRecipe();
            if (ServiceRecipe.Save(recipe))
            {
                if (AuthUser.Role != "Admin")
                {
                    AuthUser.Role = "RecipeCreator";
                }
                AuthUser.RecipeCreator = recipe.RecipeCreator;
                MessageBox.Show("Your recipe has been created successfully!");

                FragmentCreateRecipe fragmentCreateRecipe = new FragmentCreateRecipe();

                PageHome.SetButtonActive(PageHome.GlobalButtonCreate, true);

                NavigationService.Navigate(fragmentCreateRecipe);
            }
            else
            {
                ServiceRecipeCreator.Remove(recipe.RecipeCreator);
                MessageBox.Show("Something went wrong, your recipe has not been created!");
            }
        }