-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeed.cs
118 lines (117 loc) · 5.78 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 PokemonReviewApp.Postgres;
using PokemonReviewApp.Models;
namespace PokemonReviewApp
{
public class Seed
{
private readonly DataContext dataContext;
public Seed(DataContext context)
{
this.dataContext = context;
}
public void SeedDataContext()
{
if (!dataContext.PokemonOwners.Any())
{
var pokemonOwners = new List<PokemonOwner>()
{
new PokemonOwner()
{
Pokemon = new Pokemon()
{
Name = "Pikachu",
BirthDate = (new DateTime(1903,1,1)).ToUniversalTime(),
PokemonCategories = new List<PokemonCategory>()
{
new PokemonCategory { Category = new Category() { Name = "Electric"}}
},
Reviews = new List<Review>()
{
new Review { Title="Pikachu",Text = "Pickahu is the best pokemon, because it is electric", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Teddy", LastName = "Smith" } },
new Review { Title="Pikachu", Text = "Pickachu is the best a killing rocks", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Taylor", LastName = "Jones" } },
new Review { Title="Pikachu",Text = "Pickchu, pickachu, pikachu", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Jessica", LastName = "McGregor" } },
}
},
Owner = new Owner()
{
FirstName = "Jack",
LastName = "London",
Gym = "Brocks Gym",
Country = new Country()
{
Name = "Kanto"
}
}
},
new PokemonOwner()
{
Pokemon = new Pokemon()
{
Name = "Squirtle",
BirthDate = (new DateTime(1903,1,1)).ToUniversalTime(),
PokemonCategories = new List<PokemonCategory>()
{
new PokemonCategory { Category = new Category() { Name = "Water"}}
},
Reviews = new List<Review>()
{
new Review { Title= "Squirtle", Text = "squirtle is the best pokemon, because it is electric", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Teddy", LastName = "Smith" } },
new Review { Title= "Squirtle",Text = "Squirtle is the best a killing rocks", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Taylor", LastName = "Jones" } },
new Review { Title= "Squirtle", Text = "squirtle, squirtle, squirtle", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Jessica", LastName = "McGregor" } },
}
},
Owner = new Owner()
{
FirstName = "Harry",
LastName = "Potter",
Gym = "Mistys Gym",
Country = new Country()
{
Name = "Saffron City"
}
}
},
new PokemonOwner()
{
Pokemon = new Pokemon()
{
Name = "Venasuar",
BirthDate = (new DateTime(1903,1,1)).ToUniversalTime(),
PokemonCategories = new List<PokemonCategory>()
{
new PokemonCategory { Category = new Category() { Name = "Leaf"}}
},
Reviews = new List<Review>()
{
new Review { Title="Veasaur",Text = "Venasuar is the best pokemon, because it is electric", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Teddy", LastName = "Smith" } },
new Review { Title="Veasaur",Text = "Venasuar is the best a killing rocks", Rating = 5,
Reviewer = new Reviewer(){ FirstName = "Taylor", LastName = "Jones" } },
new Review { Title="Veasaur",Text = "Venasuar, Venasuar, Venasuar", Rating = 1,
Reviewer = new Reviewer(){ FirstName = "Jessica", LastName = "McGregor" } },
}
},
Owner = new Owner()
{
FirstName = "Ash",
LastName = "Ketchum",
Gym = "Ashs Gym",
Country = new Country()
{
Name = "Millet Town"
}
}
}
};
dataContext.PokemonOwners.AddRange(pokemonOwners);
dataContext.SaveChanges();
}
}
}
}