internal static void InitialCourseSeed(SchoolDbContext db, int count) { var courses = new List <Course>(); for (int i = 0; i < count; i++) { DateTime startDate = DateGenerator.GenerateDate(); DateTime endDAte = DateGenerator.GenerateEndDate(startDate); var price = Convert.ToDecimal(rnd.NextDouble() * 600); var name = courseNames[rnd.Next(0, courseNames.Length)]; Course course = new Course() { Name = name, StartDate = startDate, EndDate = endDAte, Price = price, Description = name + " " + startDate.Date.ToShortDateString() + " " + endDAte.Date.ToShortDateString() + " " + Math.Round(price) + "lv." }; courses.Add(course); } db.Courses.AddRange(courses); db.SaveChanges(); }
public static void InitialHomeworkSeed(SchoolDbContext db, int count) { var homeworks = new List <Homework>(); for (int i = 0; i < count; i++) { var homework = new Homework() { Content = contents[rnd.Next(0, contents.Length)], SubmissionDate = DateGenerator.GenerateDate(), ContentType = types[rnd.Next(0, types.Length)], StudentId = GetRandomStudentFromDb(), CourseId = GetRandomCourseFromDb() }; homeworks.Add(homework); } db.Homeworks.AddRange(homeworks); db.SaveChanges(); }
public static void InitialStudentSeed(SchoolDbContext db, int count) { var students = new List <Student>(); for (int i = 0; i < count; i++) { string name = NameGenerator.FirstName() + " " + NameGenerator.LastName(); DateTime registeredOn = DateGenerator.GenerateDate(); string phoneNumber = PhoneNumberGenerator.NewPhoneNumber(); var student = new Student() { Name = name, PhoneNumber = phoneNumber, RegisteredOn = registeredOn }; students.Add(student); } db.Students.AddRange(students); }