internal static void Main(string[] args) { Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemContext, Configuration>()); using (var db = new StudentSystemContext()) { var material = new Material { Content = "za sega njama" }; db.Materials.Add(material); var course = new Course { Name = "Algorihms", Description = "gadno" }; course.Materials.Add(material); db.Courses.Add(course); var student = new Student { Name = "Pesho", Number = 10000 }; student.Cources.Add(course); db.Students.Add(student); db.SaveChanges(); } }
private static int AddCourseMaterial(StudentSystemData data) { Material material = new Material { Name = "JSAdvanced Simulating OOP Homework", Link = "https://softuni.bg/downloads/svn/javascript-oop/March-2015/2.%20Simulating-OOP-in-JavaScript-Homework.docx", MaterialType = MaterialType.HomeworkAssignment }; data.Materials.Add(material); return data.SaveChanges(); }
public IHttpActionResult Create(Material material) { if (!this.ModelState.IsValid) { return this.BadRequest(this.ModelState); } this.StudentSystemData.Materials.Add(material); this.StudentSystemData.SaveChanges(); return this.CreatedAtRoute("DefaultApi", new { id = material.MaterialId }, material); }
static void Main() { Database.SetInitializer(new MigrateDatabaseToLatestVersion <StudentSystemContext, Configuration>()); var context = new StudentSystemContext(); var course = new Course { Name = "Database" }; var student = new Student { StudentNumber = 31150 }; student.Name = "Pesho Petrov"; course.Students.Add(student); student.Courses.Add(course); var homework = new Homework { SendDate = DateTime.Now, CourseId = 1, StudentId = 1 }; var lecture = new Material { CourseId = 1 }; student.Homeworks.Add(homework); course.Materials.Add(lecture); course.Homeworks.Add(homework); context.Courses.Add(course); context.Students.Add(student); context.Homeworks.Add(homework); context.Materials.Add(lecture); context.SaveChanges(); }
private static int AddCourseWithMaterials(StudentSystemData data) { Course course = new Course { Name = "JS Advanced", Description = "JavaScript course for advanced programmers", StartDate = new DateTime(2015, 02, 27), EndDate = new DateTime(2015, 04, 21), Price = 0m }; Material material = new Material { Name = "JSAdvanced Function Expressions Demo", Link = "https://github.com/SoftUni/Advanced-JavaScript/tree/master/1.%20Functions-and-Function-Expressions", MaterialType = MaterialType.CodeStubs }; data.Materials.Add(material); course.Materials.Add(material); //material.Courses.Add(course); data.Courses.Add(course); return data.SaveChanges(); }