Ejemplo n.º 1
0
        public static void Startup(TestContext testcontext)
        {
            Subject subject1 = new Subject() { Name = "Init subject" };
            Subject subject2 = new Subject() { Name = "Init subject2" };
            using (var sc = new SubjectContext())
            {
                sc.AddNewSubject(subject1);
                sc.AddNewSubject(subject2);
            }

            Class class1 = new Class() { Name = "Init class" };
            Class class2 = new Class() { Name = "Init class2" };
            using (var cc = new ClassContext())
            {
                cc.AddNewClass(class1);
                cc.AddNewClass(class2);
            }

            ICollection<Subject> subjects = new ObservableCollection<Subject>();
            ICollection<Class> classes = new ObservableCollection<Class>();

            subjects.Add(subject1);
            subjects.Add(subject2);

            classes.Add(class1);
            classes.Add(class2);

            Teacher newTeacher = new Teacher()
            {
                FirstName = "Ja",
                LastName = "Hallo",
                SocialSecurityNumber = 010203,
                Address = "Hallovej 123",
                ZipCode = 5678,
                City = "Viborg",
                Subjects = subjects,
                Classes = classes
            };
            using (var tc = new TeacherContext())
            {
                tc.AddNewTeacher(newTeacher);
            }
        }
 /// <summary>
 /// Add Classes to ClassComboboxItem and to ClassList
 /// </summary>
 private void addClassesToList()
 {
     using (ClassContext cc = new ClassContext())
     {
         classList = cc.GetAllClasses();
     }
     foreach (Class item in classList)
     {
         ClassComboboxItem.Add(new ComboboxItemViewModel
         {
             IsSelected = (PersonData as TeacherListItemViewData).Classes.Any(f => f.Id == item.Id),
             Name = item.Name,
             Id = item.Id
         });
     }
 }
Ejemplo n.º 3
0
        public void AddNewTeacherClassesAndSubjectsToDb()
        {
            bool success = false;

            Subject subject1 = new Subject() { Name = "Test subject" };
            Subject subject2 = new Subject() { Name = "Test subject2" };
            using (var sc = new SubjectContext())
            {
                sc.AddNewSubject(subject1);
                sc.AddNewSubject(subject2);
            }

            Class class1 = new Class() { Name = "Test class" };
            Class class2 = new Class() { Name = "Test class2" };
            using (var cc = new ClassContext())
            {
                cc.AddNewClass(class1);
                cc.AddNewClass(class2);
            }

            ICollection<Subject> subjects = new ObservableCollection<Subject>();
            ICollection<Class> classes = new ObservableCollection<Class>();

            subjects.Add(subject1);
            subjects.Add(subject2);

            classes.Add(class1);
            classes.Add(class2);

            Teacher newTeacher = new Teacher()
            {
                FirstName = "Fornavn",
                LastName = "Efternavn",
                SocialSecurityNumber = 010170,
                Address = "Hallovej 123",
                ZipCode = 1234,
                City = "Randers ikke",
                Subjects = subjects,
                Classes = classes
            };
            using (var tc = new TeacherContext())
            {
                success = tc.AddNewTeacher(newTeacher);
            }
            Assert.IsTrue(success);
        }