private DBData() { context = new ELContext(); }
public void CreateCourseMock() { using (ELContext context = new ELContext()) { var kurs1 = new Course() { Name = "C# .Net", Description = "This is basic foundation for C#", Teacher = new Teacher() { TeacherProfile = new TeacherProfile() { FirstName = "Aidin", LastName = "Mashinchi", Contact = "76576876868", Email = "*****@*****.**", Password = "******" } }, Lectures = 3, TotalHours = 90, CourseCategories = new List <CourseCategory>() { new CourseCategory { Category = new Category { Id = 1 } } }, Topics = new List <Topic>() { new Topic { Name = "Topic Foundation 1" }, new Topic { Name = "Important Before You Start" }, new Topic { Name = "Programming Languages" }, new Topic { Name = "Compilers vs Interpreters" }, new Topic { Name = "History About C# Language" }, new Topic { Name = "Object-oriented Programming" }, new Topic { Name = "Overloaded Methods Exercise" }, new Topic { Name = "Abstraction " }, new Topic { Name = "Inheritance" }, new Topic { Name = "Encapsulation" }, new Topic { Name = "Non-generic Hashtable" }, new Topic { Name = "Generic List <T>" }, new Topic { Name = "NameValueCollection" }, new Topic { Name = "Nested Tuples" } } }; var kurs2 = new Course() { Name = "Project Management", Description = "Project Management course", Teacher = new Teacher() { TeacherProfile = new TeacherProfile() { FirstName = "Abhinav", LastName = "Parankusham", Contact = "4321421434234", Email = "*****@*****.**", Password = "******" } }, Lectures = 2, TotalHours = 40, CourseCategories = new List <CourseCategory>() { new CourseCategory { Category = new Category { Id = 2 } } }, Topics = new List <Topic>() { new Topic { Name = "Agile Foundation 1" }, new Topic { Name = "Resource Management" }, new Topic { Name = "Queries, Charts and Dashboards" }, new Topic { Name = "Task boards and other features." }, new Topic { Name = "Capacity Planning, Notifications" }, new Topic { Name = "Create custom process" }, new Topic { Name = "Review and PDF of Lecture" }, new Topic { Name = "Scrum Management" }, new Topic { Name = "work items" }, new Topic { Name = "Integration with Excel" } } }; context.Attach(kurs1); context.Attach(kurs2); ShowEntityStatuses(context.ChangeTracker.Entries()); context.Courses.Add(kurs1); context.Courses.Add(kurs2); context.SaveChanges(); MessageBox.Show("Course and Teachers Created"); } }