Revize fc0e5b36
Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)
Backend/Core/Seeding/Seeder.cs | ||
---|---|---|
16 | 16 |
{ |
17 | 17 |
if (!context.Documents.Any()) |
18 | 18 |
{ |
19 |
DocumentContent content = new DocumentContent() { Content = "Dummy content" }; |
|
19 |
DocumentContent content = new DocumentContent() |
|
20 |
{ |
|
21 |
Content = "Dummy content" |
|
22 |
}; |
|
20 | 23 |
context.DocumentContents.Add(content); |
21 | 24 |
|
22 |
User user = new User() { Username = "testuser", Name = "Test", Surname = "User", Password = "password", Role = ERole.ANNOTATOR }; |
|
25 |
User user = new User() |
|
26 |
{ |
|
27 |
Username = "testuser", |
|
28 |
Name = "Test", |
|
29 |
Surname = "User", |
|
30 |
Password = "password", |
|
31 |
Role = ERole.ANNOTATOR |
|
32 |
}; |
|
23 | 33 |
context.Users.Add(user); |
24 | 34 |
|
25 |
Document document = new Document() { Content = content, Name = "Test document", DateAdded = DateTime.Now, Length = 10, RequiredAnnotations = 3, UserAdded = user }; |
|
35 |
Document document = new Document() |
|
36 |
{ |
|
37 |
Content = content, |
|
38 |
Name = "Test document", |
|
39 |
DateAdded = DateTime.Now, |
|
40 |
Length = 10, |
|
41 |
RequiredAnnotations = 3, |
|
42 |
UserAdded = user |
|
43 |
}; |
|
26 | 44 |
context.Documents.Add(document); |
27 | 45 |
context.SaveChanges(); |
28 | 46 |
|
... | ... | |
38 | 56 |
}; |
39 | 57 |
context.Annotations.Add(annotation); |
40 | 58 |
|
41 |
Class clss = new Class() { Color = "rgb(...)", Description = "Dummy description", Name = "Dummy class name" }; |
|
59 |
Class clss = new Class() |
|
60 |
{ |
|
61 |
Color = "rgb(...)", |
|
62 |
Description = "Dummy description", |
|
63 |
Name = "Dummy class name" |
|
64 |
}; |
|
42 | 65 |
context.Classes.Add(clss); |
43 | 66 |
|
44 | 67 |
annotation.Classes.Add(clss); |
45 | 68 |
|
46 |
TagCategory category = new TagCategory() { Name = "Dummy category", Color = "rgb(...)", Description = "Dummy category description" }; |
|
69 |
TagCategory category = new TagCategory() |
|
70 |
{ |
|
71 |
Name = "Dummy category", |
|
72 |
Color = "rgb(...)", |
|
73 |
Description = "Dummy category description" |
|
74 |
}; |
|
47 | 75 |
context.TagCategories.Add(category); |
48 | 76 |
|
49 |
Tag tag = new Tag() { Name = "Dummy tag", Category = category, Description = "Dummy tag", Color = "rgb(...)" }; |
|
77 |
Tag tag = new Tag() |
|
78 |
{ |
|
79 |
Name = "Dummy tag", |
|
80 |
Category = category, |
|
81 |
Description = "Dummy tag", |
|
82 |
Color = "rgb(...)" |
|
83 |
}; |
|
50 | 84 |
context.Tags.Add(tag); |
51 |
SubTag subTag = new SubTag() { Description = "Dummy subtag", Name = "Dummy subtag", Tag = tag }; |
|
85 |
SubTag subTag = new SubTag() |
|
86 |
{ |
|
87 |
Description = "Dummy subtag", |
|
88 |
Name = "Dummy subtag", |
|
89 |
Tag = tag |
|
90 |
}; |
|
52 | 91 |
context.SubTags.Add(subTag); |
53 | 92 |
|
54 |
AnnotationTag annotationTag = new AnnotationTag() { Annotation = annotation, Instance = 0, Length = 1, Position = 0, Tag = tag, Note = "Dummy note" }; |
|
93 |
AnnotationTag annotationTag = new AnnotationTag() |
|
94 |
{ |
|
95 |
Annotation = annotation, |
|
96 |
Instance = 0, |
|
97 |
Length = 1, |
|
98 |
Position = 0, |
|
99 |
Tag = tag, |
|
100 |
Note = "Dummy note" |
|
101 |
}; |
|
55 | 102 |
context.AnnotationTags.Add(annotationTag); |
56 | 103 |
|
57 | 104 |
context.SaveChanges(); |
... | ... | |
62 | 109 |
{ |
63 | 110 |
if (!context.Documents.Any()) |
64 | 111 |
{ |
65 |
User admin = new User() { Name = "Admin", Surname = "Admin", Role = ERole.ADMINISTRATOR, Username = "admin", Password = "123a456b789c" }; |
|
112 |
User admin = new User() |
|
113 |
{ |
|
114 |
Name = "Admin", |
|
115 |
Surname = "Admin", |
|
116 |
Role = ERole.ADMINISTRATOR, |
|
117 |
Username = "admin", |
|
118 |
Password = "123a456b789c" |
|
119 |
}; |
|
66 | 120 |
context.Users.Add(admin); |
67 | 121 |
context.SaveChanges(); |
68 | 122 |
} |
Také k dispozici: Unified diff
Changed formatting, added comments, database check