-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeed.cs
45 lines (44 loc) · 1.22 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
using ParonAPI.Data;
using ParonAPI.Models;
namespace ParonAPI
{
public class Seed
{
private readonly DataContext dataContext;
public Seed(DataContext context)
{
this.dataContext = context;
}
public void SeedDataContext()
{
if (!dataContext.Users.Any())
{
var Users = new List<User>()
{
new User("kitiAdmin", "admin", "test@example.com", 'a')
{
School = new School("Kiti"),
Firstname = "Admin-Kiti"
}
};
dataContext.Users.AddRange(Users);
dataContext.SaveChanges();
}
if (!dataContext.Days.Any())
{
var Days = new List<Day>()
{
new Day(1),
new Day(2),
new Day(3),
new Day(4),
new Day(5),
new Day(6),
new Day(7)
};
dataContext.Days.AddRange(Days);
dataContext.SaveChanges();
}
}
}
}