/// <summary>
        /// Создание нового объекта StudentGroupSpecial.
        /// </summary>
        /// <param name="id">Исходное значение свойства Id.</param>
        /// <param name="groupName">Исходное значение свойства GroupName.</param>
        /// <param name="flag">Исходное значение свойства Flag.</param>
        public static StudentGroupSpecial CreateStudentGroupSpecial(global::System.Int32 id, global::System.String groupName, global::System.Boolean flag)
        {
            StudentGroupSpecial studentGroupSpecial = new StudentGroupSpecial();

            studentGroupSpecial.Id        = id;
            studentGroupSpecial.GroupName = groupName;
            studentGroupSpecial.Flag      = flag;
            return(studentGroupSpecial);
        }
Example #2
0
        /// <summary>
        /// Заполнение данных
        /// </summary>
        static void InitData()
        {
            LearningModelContainer db = new LearningModelContainer();

            //Добавление типов предметов

            SubjectType st_tech = new SubjectType
            {
                TypeName          = "технический цикл",
                ParentSubjectType = null
            };

            db.SubjectTypeSet.AddObject(st_tech);

            SubjectType st_hum = new SubjectType
            {
                TypeName          = "гуманитарный цикл",
                ParentSubjectType = null
            };

            SubjectType st1 = new SubjectType
            {
                TypeName          = "базовые",
                ParentSubjectType = st_tech
            };

            SubjectType st2 = new SubjectType
            {
                TypeName          = "специальные",
                ParentSubjectType = st_tech
            };

            SubjectType st3 = new SubjectType
            {
                TypeName          = "исторические",
                ParentSubjectType = st_hum
            };

            SubjectType st3_1 = new SubjectType
            {
                TypeName          = "новая история",
                ParentSubjectType = st3
            };

            SubjectType st3_2 = new SubjectType
            {
                TypeName          = "новейшая история",
                ParentSubjectType = st3
            };

            db.SubjectTypeSet.AddObject(st_tech);
            db.SubjectTypeSet.AddObject(st_hum);
            db.SubjectTypeSet.AddObject(st1);
            db.SubjectTypeSet.AddObject(st2);
            db.SubjectTypeSet.AddObject(st3);
            db.SubjectTypeSet.AddObject(st3_1);
            db.SubjectTypeSet.AddObject(st3_2);

            //Добавление предметов

            Subject sb1 = new Subject
            {
                SubjectName = "математика",
                Value       = 100, //часов
                SubjectType = st1
            };

            Subject sb2 = new Subject
            {
                SubjectName = "физика",
                Value       = 80, //часов
                SubjectType = st1
            };

            Subject sb3 = new Subject
            {
                SubjectName = "информатика",
                Value       = 120, //часов
                SubjectType = st2
            };

            Subject sb4 = new Subject
            {
                SubjectName = "базы данных",
                Value       = 150, //часов
                SubjectType = st2
            };

            Subject sb5 = new Subject
            {
                SubjectName = "сетевые технологии",
                Value       = 170, //часов
                SubjectType = st2
            };

            db.SubjectSet.AddObject(sb1);
            db.SubjectSet.AddObject(sb2);
            db.SubjectSet.AddObject(sb3);
            db.SubjectSet.AddObject(sb4);
            db.SubjectSet.AddObject(sb5);

            //Добавление групп

            StudentGroup g1 = new StudentGroup
            {
                GroupName = "ИУ5-11"
            };

            StudentGroup g2 = new StudentGroup
            {
                GroupName = "ИУ5-51"
            };

            StudentGroupSpecial g3 = new StudentGroupSpecial
            {
                GroupName = "ИУ5c-11",
                Flag      = true
            };

            db.StudentGroupSet.AddObject(g1);
            db.StudentGroupSet.AddObject(g2);
            db.StudentGroupSet.AddObject(g3);

            //Установка связи много-ко многим

            g1.Subject.Add(sb1);
            g1.Subject.Add(sb2);

            g2.Subject.Add(sb3);
            g2.Subject.Add(sb4);
            g2.Subject.Add(sb5);

            g3.Subject.Add(sb1);
            g3.Subject.Add(sb2);
            g3.Subject.Add(sb4);

            //Сохранение данных в БД
            db.SaveChanges();
        }