-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seed.cs
118 lines (117 loc) · 5.55 KB
/
Seed.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using AnimalReviewApp.Data;
using AnimalReviewApp.Model;
namespace AnimalReviewApp
{
public class Seed
{
private readonly DataContext dataContext;
public Seed(DataContext context)
{
this.dataContext = context;
}
public void SeedDataContext()
{
if (!dataContext.AnimalOwners.Any())
{
var AnimalOwners = new List<AnimalOwner>()
{
new AnimalOwner()
{
Animal = new Animal()
{
Name = "Pies",
BirthDate = new DateTime(1903,1,1),
AnimalCategories = new List<AnimalCategory>()
{
new AnimalCategory { Category = new Category() { Name = "Ssak"}}
},
Reviews = new List<Review>()
{
new Review { Title="Pies",Text = "Super szybki psiak", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Jan", LastName = "Kowalski" } },
new Review { Title="Pies", Text = "Pies super szybko biega", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Krzysztof", LastName = "Nowak" } },
new Review { Title="Pies",Text = "Pies jest gorszy od kota", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Karolina", LastName = "Dec" } },
}
},
Owner = new Owner()
{
FirstName = "Jan",
LastName = "Palikot",
School = "Szkoła psinek",
Country = new Country()
{
Name = "Polska"
}
}
},
new AnimalOwner()
{
Animal = new Animal()
{
Name = "Rekin",
BirthDate = new DateTime(1903,1,1),
AnimalCategories = new List<AnimalCategory>()
{
new AnimalCategory { Category = new Category() { Name = "Ryba"}}
},
Reviews = new List<Review>()
{
new Review { Title= "Rekin", Text = "Rekin ma super płetwe", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Kamil", LastName = "Stoch" } },
new Review { Title= "Rekin",Text = "Rekin oddycha pod wodą", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Andrzej", LastName = "Duda" } },
new Review { Title= "Rekin", Text = "Wodny skurczybyk, zjadł mi psa", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Anna", LastName = "Mucha" } },
}
},
Owner = new Owner()
{
FirstName = "Mateusz",
LastName = "Morawiecki",
School = "Szkoła rekinów",
Country = new Country()
{
Name = "Rosja"
}
}
},
new AnimalOwner()
{
Animal = new Animal()
{
Name = "Żółw",
BirthDate = new DateTime(1903,1,1),
AnimalCategories = new List<AnimalCategory>()
{
new AnimalCategory { Category = new Category() { Name = "Gad"}}
},
Reviews = new List<Review>()
{
new Review { Title="Żółw",Text = "Żółw ma turbo skorupe", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Janina", LastName = "Mostkowiak" } },
new Review { Title="Żółw",Text = "Zółw bezciała robi za freesbe", Rating = 4,
Reviewer = new Reviewer(){ FirstName = "Kuba", LastName = "Wojewódzki" } },
new Review { Title="Żółw",Text = "Za długo żyje", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Maryla", LastName = "Rodowicz" } },
}
},
Owner = new Owner()
{
FirstName = "Karol",
LastName = "Nowicki",
School = "Szkoła żółwi",
Country = new Country()
{
Name = "Czechy"
}
}
}
};
dataContext.AnimalOwners.AddRange(AnimalOwners);
dataContext.SaveChanges();
}
}
}
}