study-lib-backend/API/Data/StudyLibDataSeeder.cs

69 lines
1.7 KiB
C#
Raw Permalink Normal View History

2020-12-12 14:47:20 +01:00
using System;
using System.Linq;
using StudyLib.API.Models;
using StudyLib.Models;
namespace StudyLib.API.Data
{
public class StudyLibDataSeeder
{
public static void Initialize(StudyLibContext context)
{
2020-12-23 23:35:08 +01:00
/* if (context.Subjects.Any())
2020-12-12 14:47:20 +01:00
{
return;
}
context.Subjects.AddRange(
new Subject
{
Name = "Test",
LectureTeacher = "Jan Kowalski",
LabTeacher = "Adam Nowak",
MainExam = true,
ExamDate = new DateTime(2020, 12, 10)
}
);
context.SaveChanges();
long addedSubjectID = context.Subjects.Where(subject => subject.Name == "Test").Select(subject => subject.ID).FirstOrDefault();
context.Assignments.Add(
new Assignment
{
Name = "test",
Deadline = new DateTime(2020, 12, 10),
Description = "test",
FinalMarkPercent = 100.1,
SubjectId = addedSubjectID
}
);
context.Tests.Add(
new Test
{
Date = new DateTime(2020, 12, 10),
Scope = "Full subject",
FinalMarkPercent = 100.1,
SubjectId = addedSubjectID
}
);
context.Comments.Add(
new Comment
{
Text = "test",
SubjectId = addedSubjectID
}
);
2020-12-23 23:35:08 +01:00
context.SaveChanges();*/
2020-12-12 14:47:20 +01:00
}
}
}