Skip to content

Commit aec724d

Browse files
authored
Merge pull request #133 from nesfit/faeture/lecture-09
Faeture/lecture 09
2 parents aa16c05 + ae26c6c commit aec724d

10 files changed

Lines changed: 1025 additions & 26 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:ca99abcb3b88cc7d58b4a24167d2f85b43cae8540f6852b1df05f716f05723e9
3-
size 190761
2+
oid sha256:9399ff776b698fa71d97605c45b98a0bf868b83ea8fea9f3cddd3723644cc034
3+
size 166622

src/CookBook/CookBook.App/CookBook.App.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474

7575
<ItemGroup>
76+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
7677
<PackageReference Include="Microsoft.Maui.Controls" />
7778
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" />
7879

@@ -81,6 +82,7 @@
8182
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
8283
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
8384
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
85+
<PackageReference Include="Microsoft.Maui.DevFlow.Agent" />
8486
<PackageReference Include="ServiceScan.SourceGenerator">
8587
<PrivateAssets>all</PrivateAssets>
8688
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

src/CookBook/CookBook.App/MauiProgram.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
using CommunityToolkit.Maui;
1+
using System.Reflection;
2+
using CommunityToolkit.Maui;
23
using CookBook.App.Services;
34
using CookBook.BL;
4-
using Microsoft.Extensions.Configuration;
5-
using System.Reflection;
65
using CookBook.DAL;
76
using CookBook.DAL.Migrator;
87
using CookBook.DAL.Options;
98
using CookBook.DAL.Seeds;
9+
using Microsoft.Maui.DevFlow.Agent;
10+
using Microsoft.Extensions.Configuration;
1011
using Microsoft.Extensions.Options;
11-
using Microsoft.Maui.Storage;
1212

1313
[assembly:System.Resources.NeutralResourcesLanguage("en")]
1414
namespace CookBook.App;
@@ -33,6 +33,10 @@ public static MauiApp CreateMauiApp()
3333
.AddBLServices()
3434
.AddAppServices();
3535

36+
#if DEBUG
37+
builder.AddMauiDevFlowAgent();
38+
#endif
39+
3640
var app = builder.Build();
3741

3842
AssertDALOptionsConfiguration(app);

src/CookBook/CookBook.App/Views/Ingredient/IngredientListView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
HorizontalOptions="End" VerticalOptions="Start"
2222
Text="{x:Static texts:IngredientListViewTexts.Add_Button_Text}"
2323
Command="{Binding GoToCreateCommand}"
24-
CornerRadius="5" FontFamily="MontserratMedium"
24+
CornerRadius="5"
2525
FontSize="14"
2626
Style="{StaticResource PrimaryButtonStyle}" />
2727

src/CookBook/CookBook.App/Views/Recipe/RecipeListView.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
x:Name="RecipeListViewRoot"
1212
Style="{StaticResource ContentPageStyle}">
1313
<Grid>
14-
<Grid HorizontalOptions="FillAndExpand"
14+
<Grid HorizontalOptions="Fill"
1515
RowDefinitions="Auto, *"
1616
RowSpacing="20"
1717
Margin="{OnIdiom Phone='10, 0'}">
@@ -20,7 +20,7 @@
2020
Text="{x:Static t:RecipeListViewTexts.Title_Label}" />
2121

2222
<CollectionView Grid.Row="1" ItemsSource="{Binding Recipes}"
23-
VerticalOptions="FillAndExpand">
23+
VerticalOptions="Fill">
2424
<CollectionView.ItemsLayout>
2525
<GridItemsLayout Orientation="Horizontal"
2626
HorizontalItemSpacing="10" VerticalItemSpacing="10"
@@ -88,7 +88,7 @@
8888
HorizontalOptions="End" VerticalOptions="Start"
8989
Text="{x:Static t:RecipeListViewTexts.Add_Button_Text}"
9090
Command="{Binding GoToCreateCommand}"
91-
CornerRadius="5" FontFamily="MontserratMedium"
91+
CornerRadius="5"
9292
FontSize="14"
9393
Style="{StaticResource PrimaryButtonStyle}" />
9494
</Grid>

src/CookBook/CookBook.DAL/Seeds/DbSeeder.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,46 @@ public void Seed()
2727
dbContext.Set<IngredientEntity>().Add(IngredientSeeds.Water);
2828
}
2929

30+
foreach (var ingredient in new[]
31+
{
32+
IngredientSeeds.Tomato, IngredientSeeds.Onion, IngredientSeeds.Garlic,
33+
IngredientSeeds.OliveOil, IngredientSeeds.Salt, IngredientSeeds.GroundBeef,
34+
IngredientSeeds.Spaghetti, IngredientSeeds.ChickenBreast, IngredientSeeds.BellPepper,
35+
IngredientSeeds.SoySauce, IngredientSeeds.Banana, IngredientSeeds.Milk,
36+
IngredientSeeds.Honey, IngredientSeeds.Flour, IngredientSeeds.Egg,
37+
IngredientSeeds.Butter, IngredientSeeds.ChocolateChips, IngredientSeeds.Sugar,
38+
IngredientSeeds.Carrot, IngredientSeeds.Potato, IngredientSeeds.Beef,
39+
IngredientSeeds.CocoaPowder, IngredientSeeds.Bread,
40+
})
41+
{
42+
if (!dbContext.Set<IngredientEntity>().Any(i => i.Id == ingredient.Id))
43+
{
44+
dbContext.Set<IngredientEntity>().Add(ingredient);
45+
}
46+
}
47+
3048
if (!dbContext.Set<RecipeEntity>().Any(i => i.Id == RecipeSeeds.LemonadeRecipe.Id))
3149
{
3250
dbContext.Set<RecipeEntity>().Add(
3351
RecipeSeeds.LemonadeRecipe with { Ingredients = new List<IngredientAmountEntity>() });
3452
}
3553

54+
foreach (var recipe in new[]
55+
{
56+
RecipeSeeds.TomatoSoupRecipe, RecipeSeeds.SpaghettiBoLogneseRecipe,
57+
RecipeSeeds.ChickenStirFryRecipe, RecipeSeeds.BananaSmoothieRecipe,
58+
RecipeSeeds.ChocolateChipCookiesRecipe, RecipeSeeds.ScrambledEggsRecipe,
59+
RecipeSeeds.PancakesRecipe, RecipeSeeds.BeefStewRecipe,
60+
RecipeSeeds.HotChocolateRecipe, RecipeSeeds.GarlicBreadRecipe,
61+
})
62+
{
63+
if (!dbContext.Set<RecipeEntity>().Any(r => r.Id == recipe.Id))
64+
{
65+
dbContext.Set<RecipeEntity>().Add(
66+
recipe with { Ingredients = new List<IngredientAmountEntity>() });
67+
}
68+
}
69+
3670
if (!dbContext.Set<IngredientAmountEntity>().Any(i => i.Id == IngredientAmountSeeds.LemonadeLemon.Id))
3771
{
3872
dbContext.Set<IngredientAmountEntity>().Add(
@@ -45,6 +79,43 @@ public void Seed()
4579
IngredientAmountSeeds.LemonadeWater with { Recipe = null!, Ingredient = null! });
4680
}
4781

82+
foreach (var ia in new[]
83+
{
84+
IngredientAmountSeeds.TomatoSoupTomato, IngredientAmountSeeds.TomatoSoupOnion,
85+
IngredientAmountSeeds.TomatoSoupGarlic, IngredientAmountSeeds.TomatoSoupOliveOil,
86+
IngredientAmountSeeds.TomatoSoupSalt,
87+
IngredientAmountSeeds.SpagBolGroundBeef, IngredientAmountSeeds.SpagBolSpaghetti,
88+
IngredientAmountSeeds.SpagBolTomato, IngredientAmountSeeds.SpagBolOnion,
89+
IngredientAmountSeeds.SpagBolGarlic, IngredientAmountSeeds.SpagBolOliveOil,
90+
IngredientAmountSeeds.StirFryChickenBreast, IngredientAmountSeeds.StirFryBellPepper,
91+
IngredientAmountSeeds.StirFryOnion, IngredientAmountSeeds.StirFrySoySauce,
92+
IngredientAmountSeeds.StirFryGarlic,
93+
IngredientAmountSeeds.SmoothieBanana, IngredientAmountSeeds.SmoothieMilk,
94+
IngredientAmountSeeds.SmoothieHoney,
95+
IngredientAmountSeeds.CookiesFlour, IngredientAmountSeeds.CookiesButter,
96+
IngredientAmountSeeds.CookiesSugar, IngredientAmountSeeds.CookiesEgg,
97+
IngredientAmountSeeds.CookiesChocolateChips,
98+
IngredientAmountSeeds.ScrambledEggsEgg, IngredientAmountSeeds.ScrambledEggsButter,
99+
IngredientAmountSeeds.ScrambledEggsMilk, IngredientAmountSeeds.ScrambledEggsSalt,
100+
IngredientAmountSeeds.PancakesFlour, IngredientAmountSeeds.PancakesEgg,
101+
IngredientAmountSeeds.PancakesMilk, IngredientAmountSeeds.PancakesButter,
102+
IngredientAmountSeeds.PancakesSugar,
103+
IngredientAmountSeeds.StewBeef, IngredientAmountSeeds.StewCarrot,
104+
IngredientAmountSeeds.StewPotato, IngredientAmountSeeds.StewOnion,
105+
IngredientAmountSeeds.StewGarlic,
106+
IngredientAmountSeeds.HotChocMilk, IngredientAmountSeeds.HotChocCocoaPowder,
107+
IngredientAmountSeeds.HotChocSugar, IngredientAmountSeeds.HotChocHoney,
108+
IngredientAmountSeeds.GarlicBreadBread, IngredientAmountSeeds.GarlicBreadButter,
109+
IngredientAmountSeeds.GarlicBreadGarlic,
110+
})
111+
{
112+
if (!dbContext.Set<IngredientAmountEntity>().Any(i => i.Id == ia.Id))
113+
{
114+
dbContext.Set<IngredientAmountEntity>().Add(
115+
ia with { Recipe = null!, Ingredient = null! });
116+
}
117+
}
118+
48119
dbContext.SaveChanges();
49120
}
50121
}

0 commit comments

Comments
 (0)