Exemplo n.º 1
0
        //this method is used to load the recipe to the page by using its id
        private void loadRecipe(int recipeId)
        {
            dc     = new yummyDatabaseDataContext();
            recipe = dc.Recipes.Where(recipe => recipe.RecipeId == recipeId).Single();

            if (recipe.Image != null)
            {
                bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = new MemoryStream(recipe.Image.ToArray());
                bitmapImage.EndInit();
                imgRecipePhoto.Source = bitmapImage;
            }
            labelRecipeName.Content   = recipe.Name;
            txtRecipeDescription.Text = recipe.Description;
            txtRecipePrepTime.Text    = recipe.PrepTime.ToString();
            txtRecipeServings.Text    = recipe.Serving.ToString();
            txtRecipeDirections.Text  = recipe.Directions;

            string recipeIngredients = string.Empty;

            foreach (var recipeIngredient in recipe.RecipeIngredients)
            {
                recipeIngredients += $"{recipeIngredient.Quantity} {recipeIngredient.Measurement} {recipeIngredient.Ingredient.Name}\n";
            }

            txtRecipeIngrediensList.Text = recipeIngredients;
        }
Exemplo n.º 2
0
        /// <summary>
        /// method to update the recipe datagrid to reflect database changes
        /// </summary>
        private void refreshRecipies()
        {
            dc = new yummyDatabaseDataContext();
            dgRecipes.ItemsSource = null;

            // selecting specific columns to display in the recipe datagrid
            dgRecipes.ItemsSource = dc.Recipes.Select(recipe => new { recipe.RecipeId, recipe.Name, recipe.PrepTime, recipe.Serving, Category = recipe.Category1.CategoryName }).OrderBy(recipe => recipe.Name);
        }
Exemplo n.º 3
0
        // method that load the data from the table and set the carousel to the retrieved data
        private void ShowCategories()
        {
            dc = new yummyDatabaseDataContext();
            var query = (from Cat in dc.Categories orderby Cat.CategoryName ascending select Cat);

            catTable = query.ToList();
            loadDataToDisplay(catTable);
        }
Exemplo n.º 4
0
        // method that load the data from the table and set the carousel to the retrieved data
        private void ShowRecipes()
        {
            dc = new yummyDatabaseDataContext();
            var query = (from Rec in dc.Recipes orderby Rec.Name ascending select Rec);

            recTable = query.ToList();
            loadDataToDisplay(recTable);
        }
Exemplo n.º 5
0
        // method that load the data from the table and set the carousel to the retrieved data
        private void ShowCategories()
        {
            dc = new yummyDatabaseDataContext();
            // query that retrieves only the first 5 elements from the Category table ordered by the Category Name
            var query = (from Cat in dc.Categories orderby Cat.CategoryName ascending select Cat).Take(5);

            catTable = query.ToList();
            loadDataToDisplay(catTable); // loading the data in a proper format to display
        }
Exemplo n.º 6
0
        // method that load the data from the table and set the carousel to the retrieved data
        private void ShowRecipes()
        {
            dc = new yummyDatabaseDataContext();
            // query that retrieves only the first 4 elements from the Recipe table ordered by the Name
            var query = (from Rec in dc.Recipes orderby Rec.Name ascending select Rec).Take(4);

            recTable = query.ToList();
            loadDataToDisplay(recTable); // loading the data in a proper format to display
        }
Exemplo n.º 7
0
        public Shopping_Cart()
        {
            InitializeComponent();
            dc = new yummyDatabaseDataContext();
            ShopingLIstGrid.ItemsSource = null;

            // selecting specific columns to display in the recipe datagrid
            ShopingLIstGrid.ItemsSource = dc.Recipes.Select(recipe => new { recipe.RecipeId, recipe.Name, recipe.PrepTime, recipe.Serving, Category = recipe.Category1.CategoryName });
        }
Exemplo n.º 8
0
        // refresh the data from the database and load the displayable data
        private void refreshCategories()
        {
            dc = new yummyDatabaseDataContext();
            CategoriesCarousel.ItemsSource = null;

            // selecting specific columns to display in the recipe datagrid
            var catTab = (from C in dc.Categories orderby C.CategoryName ascending select C);

            loadDataToDisplay(catTab.ToList());
        }
Exemplo n.º 9
0
        // refresh the data from the database and load the displayable data
        private void refreshRecipies()
        {
            dc = new yummyDatabaseDataContext();
            RecipesCarousel.ItemsSource = null;

            // selecting specific columns to display in the recipe datagrid
            var recTab = (from R in dc.Recipes orderby R.Name ascending select R);

            loadDataToDisplay(recTab.ToList());
        }
Exemplo n.º 10
0
        public Catalog()
        {
            InitializeComponent();

            // instatiating the database connection
            dc = new yummyDatabaseDataContext();

            // load the data to the carousel
            ShowCategories();
            ShowRecipes();
        }
Exemplo n.º 11
0
 // method overloaded to load the data from the categories table, and build an object to display inside the category carousel
 private void loadDataToDisplay(List <Category> tab)
 {
     dc           = new yummyDatabaseDataContext();
     myCategories = new List <MediaData>();
     foreach (var categoryObj in tab)
     {
         MediaData cnt = new MediaData();
         if (categoryObj.CategoryImage != null)
         {
             cnt.ImageData = cnt.ByteArrayToImage(categoryObj.CategoryImage.ToArray());
         }
         cnt.Id    = categoryObj.CategoryId;
         cnt.Title = categoryObj.CategoryName;
         myCategories.Add(cnt);
     }
     CategoriesCarousel.ItemsSource = myCategories; // setting the carousel data
 }
Exemplo n.º 12
0
 // method overloaded to load the data from the categories table, and build an object to display inside the category carousel
 private void loadDataToDisplay(List <Recipe> tab)
 {
     dc        = new yummyDatabaseDataContext();
     myRecipes = new List <MediaData>();
     foreach (var recipeObj in tab)
     {
         MediaData cnt = new MediaData();
         if (recipeObj.Image != null)
         {
             cnt.ImageData = cnt.ByteArrayToImage(recipeObj.Image.ToArray());
         }
         cnt.Id          = recipeObj.RecipeId;
         cnt.Title       = recipeObj.Name;
         cnt.Description = recipeObj.Description;
         myRecipes.Add(cnt);
     }
     RecipesCarousel.ItemsSource = myRecipes;
 }
Exemplo n.º 13
0
        // method overloaded to load the data from the categories table, and build an object to display inside the category carousel
        private void loadDataToDisplay(List <Category> tab)
        {
            dc           = new yummyDatabaseDataContext();
            myCategories = new List <MediaData>();

            // for each category inside the table build a Media data instance
            foreach (var categoryObj in tab)
            {
                MediaData cnt = new MediaData();
                if (categoryObj.CategoryImage != null)
                {
                    // getting the array of bytes and converting to a displayable image
                    cnt.ImageData = cnt.ByteArrayToImage(categoryObj.CategoryImage.ToArray());
                }
                cnt.Id    = categoryObj.CategoryId;
                cnt.Title = categoryObj.CategoryName;

                // add instance of MediaData to the list that will be used inside de carousel
                myCategories.Add(cnt);
            }
            CategoriesCarousel.ItemsSource = myCategories; // setting the carousel data
        }
Exemplo n.º 14
0
        // method overloaded to load the data from the recipes table, and build an object to display inside the recipe carousel
        private void loadDataToDisplay(List <Recipe> tab)
        {
            dc        = new yummyDatabaseDataContext();
            myRecipes = new List <MediaData>();

            // for each recipe inside the table build a Media data instance
            foreach (var recipeObj in tab)
            {
                MediaData cnt = new MediaData();
                if (recipeObj.Image != null)
                {
                    // getting the array of bytes and converting to a displayable image
                    cnt.ImageData = cnt.ByteArrayToImage(recipeObj.Image.ToArray());
                }
                cnt.Id          = recipeObj.RecipeId;
                cnt.Title       = recipeObj.Name;
                cnt.Description = recipeObj.Description;

                // add instance of MediaData to the list that will be used inside de carousel
                myRecipes.Add(cnt);
            }

            RecipesCarousel.ItemsSource = myRecipes; // setting the carousel data
        }