Quellcode durchsuchen

Статичсекое меню пользователя

semen vor 5 Monaten
Ursprung
Commit
752c4886e6
2 geänderte Dateien mit 66 neuen und 7 gelöschten Zeilen
  1. 16 0
      FoodLogProject/ViewModels/MainWindowViewModel.cs
  2. 50 7
      FoodLogProject/Views/Page4.axaml

+ 16 - 0
FoodLogProject/ViewModels/MainWindowViewModel.cs

@@ -32,6 +32,7 @@ namespace FoodLogProject.ViewModels
         }
 
         Page3ViewModel page3VM;
+
         public void LoadPage3()
         {
             page3VM = new Page3ViewModel(myConnection,uc);
@@ -51,6 +52,7 @@ namespace FoodLogProject.ViewModels
             }
             else
             {
+
                 page6VM = new Page6ViewModel(currentUser, myConnection);
                 UC = new Page4();
             }
@@ -71,6 +73,20 @@ namespace FoodLogProject.ViewModels
             UC = new Page7();
         }
 
+        private Recipe recipesbreackfast = myConnection.Recipes.FirstOrDefault(x => x.RecipeId == 3);
+        private Recipe recipeslunch = myConnection.Recipes.FirstOrDefault(x => x.RecipeId == 4);
+        private Recipe recipesdinner = myConnection.Recipes.FirstOrDefault(x => x.RecipeId == 5);
+
+        private List<RecipesIngredient> listIngridientbreackfast = myConnection.RecipesIngredients.Include(x => x.Ingredient).Where(x => x.RecipeId == 3).ToList();
+        private List<RecipesIngredient> listIngridientlunch = myConnection.RecipesIngredients.Include(x => x.Ingredient).Where(x => x.RecipeId == 4).ToList();
+        private List<RecipesIngredient> listIngridientdinner = myConnection.RecipesIngredients.Include(x => x.Ingredient).Where(x => x.RecipeId == 5).ToList();
+        public List<RecipesIngredient> ListIngridientBreakfast { get => listIngridientbreackfast; set => listIngridientbreackfast = value; }
+        public List<RecipesIngredient> ListIngridientLunch { get => listIngridientlunch; set => listIngridientlunch = value; }
+        public List<RecipesIngredient> ListIngridientDinner { get => listIngridientdinner; set => listIngridientdinner = value; }
+        public Recipe Recipesbreackfast { get => recipesbreackfast; set => recipesbreackfast = value; }
+        public Recipe Recipeslunch { get => recipeslunch; set => recipeslunch = value; }
+        public Recipe Recipesdinner { get => recipesdinner; set => recipesdinner = value; }
+
 #pragma warning restore CA1822 // Mark members as static
     }
 }

+ 50 - 7
FoodLogProject/Views/Page4.axaml

@@ -1,7 +1,8 @@
 <UserControl xmlns="https://github.com/avaloniaui"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-			 xmlns:vm="using:FoodLogProject.ViewModels"               
+			 xmlns:vm="using:FoodLogProject.ViewModels"  
+			 			 x:DataType="vm:MainWindowViewModel" 
 			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:Class="FoodLogProject.Views.Page4">
@@ -35,18 +36,60 @@ Padding="40" >
 					<TextBlock FontSize="20" Foreground="DarkGreen" FontWeight="Bold" Margin="0,0,0,20" HorizontalAlignment="Center">
 						Меню
 					</TextBlock>
-					<TextBlock FontSize="16"  FontWeight="Bold" Margin="0,0,0,10">
-						1 День
-					</TextBlock>
 
 					<TextBlock FontWeight="Bold" Margin="0,0,0,10">Завтрак</TextBlock>
-					<TextBlock Name="Breakfast">место для завтрака</TextBlock>
+					<TextBlock Text="{Binding Recipesbreackfast.RecipeName}" FontSize="20" Foreground="DarkGreen"/>
+					<TextBlock FontWeight="Bold" Margin="0,0,0,10">Ингредиенты</TextBlock>
+					<ListBox ItemsSource="{Binding ListIngridientBreakfast}">
+						<ListBox.ItemTemplate>
+							<DataTemplate>
+								<StackPanel >
+
+									<TextBlock Text="{Binding Ingredient.IngredientName}"/>
+									<TextBlock Text="{Binding Weight}"/>
+								</StackPanel>
+							</DataTemplate>
+						</ListBox.ItemTemplate>
+					</ListBox>
+
+					<TextBlock FontWeight="Bold" Margin="0,10,0,10">Рецепт</TextBlock>
+					<TextBox AcceptsReturn="True" BorderBrush="White" IsReadOnly="True" TextWrapping="Wrap" Text="{Binding Recipesbreackfast.RecipeDescription}"/>
 
 					<TextBlock FontWeight="Bold" Margin="0,10,0,10">Обед</TextBlock>
-					<TextBlock Name="Lunch">место для обеда</TextBlock>
+					<TextBlock Text="{Binding Recipeslunch.RecipeName}" FontSize="20" Foreground="DarkGreen"/>
+					<TextBlock FontWeight="Bold" Margin="0,0,0,10">Ингредиенты</TextBlock>
+					<ListBox ItemsSource="{Binding ListIngridientLunch}">
+						<ListBox.ItemTemplate>
+							<DataTemplate>
+								<StackPanel >
+
+									<TextBlock Text="{Binding Ingredient.IngredientName}"/>
+									<TextBlock Text="{Binding Weight}"/>
+								</StackPanel>
+							</DataTemplate>
+						</ListBox.ItemTemplate>
+					</ListBox>
+
+					<TextBlock FontWeight="Bold" Margin="0,10,0,10">Рецепт</TextBlock>
+					<TextBox AcceptsReturn="True" BorderBrush="White" IsReadOnly="True" TextWrapping="Wrap" Text="{Binding Recipeslunch.RecipeDescription}"/>
 
 					<TextBlock FontWeight="Bold" Margin="0,10,0,10">Ужин</TextBlock>
-					<TextBlock Name="Dinner">место для ужин</TextBlock>
+					<TextBlock Text="{Binding Recipesdinner.RecipeName}" FontSize="20" Foreground="DarkGreen"/>
+					<TextBlock FontWeight="Bold" Margin="0,0,0,10">Ингредиенты</TextBlock>
+					<ListBox ItemsSource="{Binding ListIngridientDinner}">
+						<ListBox.ItemTemplate>
+							<DataTemplate>
+								<StackPanel >
+
+									<TextBlock Text="{Binding Ingredient.IngredientName}"/>
+									<TextBlock Text="{Binding Weight}"/>
+								</StackPanel>
+							</DataTemplate>
+						</ListBox.ItemTemplate>
+					</ListBox>
+
+					<TextBlock FontWeight="Bold" Margin="0,10,0,10">Рецепт</TextBlock>
+					<TextBox AcceptsReturn="True" BorderBrush="White" IsReadOnly="True" TextWrapping="Wrap" Text="{Binding Recipesdinner.RecipeDescription}"/>
 				</StackPanel>
 			</StackPanel>
 		</Border>