Пример #1
0
 public static void AddStudent(string name, string number) 
 {
     StudentSystemDB db = new StudentSystemDB();
     using (db)
     {
         Student newStudent = new Student();
         newStudent.Name = name;
         newStudent.Number = number;
        
         db.Students.Add(newStudent);
         db.SaveChanges();
     }
 }
Пример #2
0
        private static Student AddStudent(StudentSystemEntities context, string name, ICollection<Course> courses = null)
        {
            var newStudent = new Student()
            {
                Name = name,
            };

            if (courses != null)
            {
                newStudent.Courses = courses;
            }

            context.Students.Add(newStudent);
            context.SaveChanges();

            return newStudent;
        }
Пример #3
0
        private static void AddHomework(StudentSystemEntities context, string content, DateTime sentDate, Course course, Student student)
        {
            var newHomework = new Homework()
            {
                Content = content,
                TimeSent = sentDate,
                Course = course,
                Student = student
            };

            course.Homeworks.Add(newHomework);
            student.Homeworks.Add(newHomework);
            context.Homeworks.Add(newHomework);
            context.SaveChanges();
        }