Пример #1
0
 public void TestInsert_WithStandardStudent()
 {
     Student student = new Student() {
         Name = "Test",
         Surname = "Surname Test",
         Address = "Test Address",
         PersonalNumericCode = "1880617000000",
         PhoneNumber = "0700123456",
     };
     DataMapperFactories.GetActiveFactory().StudentDAO.Insert(student, connectionString);
     Int32 studentsInDatabase = DataMapperFactories.GetActiveFactory().StudentDAO.GetNumberOfStudents(connectionString);
     // assert we have one more student in the database than we previously had
     Assert.AreEqual(expectedNoOfStudentsInTheDatabase + 1, studentsInDatabase);
 }
Пример #2
0
 public void Insert(Student student, String connectionString)
 {
     var context = new UniversityEntities();
     if (connectionString != null)
     {
         if (logger.IsInfoEnabled)
         {
             logger.Info("Using the following connection string: " + connectionString);
         }
         context = new UniversityEntities(connectionString);
     }
     using (context)
     {
         if (student == null)
         {
             logger.Error("Cannot insert a null student in the database.");
         }
         else
         {
             context.Students.AddObject(student);
             context.SaveChanges();
         }
     }
 }
Пример #3
0
        private void FixupStudent(Student previousValue)
        {
            if (previousValue != null && previousValue.Classes.Contains(this))
            {
                previousValue.Classes.Remove(this);
            }

            if (Student != null)
            {
                if (!Student.Classes.Contains(this))
                {
                    Student.Classes.Add(this);
                }
            }
        }