Esempio n. 1
0
        public object AddNewLessonTrial(TrialLessonVm data)
        {
            if (data.StEmail.IsEmpty() && _regexUtilities.IsValidEmail(data.StEmail))
                return "Некорректный E-mail!";
            
            if (data.StFullName.IsEmpty())
                return "Не указано имя!";
            var student = new Student();
            var lesson = new Lesson();

            student.FullName = data.StFullName;
            student.Email = data.StEmail;
            student.Skype = data.StSkype;
            student.City = data.StCity;
            student.Age = !data.StAge.IsEmpty() ? Convert.ToInt32(data.StAge) : 0;

            lesson.Language = new Language {LanguageName = data.LsLang};
            lesson.DateTime = data.LsDateTime;
            lesson.Comment = data.LsComment;
            lesson.IsTrial = true;

            var body = RenderToString("_AddTrialLessonNotification", data);

            dispatcher.Push(new SendMessageCommand(new Email
            {
                ToEmail = MailSettings.ToEmail,
                Subject = "Заявка на пробный урок",
                Body = body
            }));
            if (data.IsIos != null)
                return RedirectToAction("Index", "Home");

            return "Success";
        }
Esempio n. 2
0
        public GridPanel(int day, int time, Color color)
            : base()
        {
            m_day = day;
            m_time = time;
            BackColor = color;
            m_lessonData = new Lesson();

            m_label = new Label();
            m_label.Location = this.Location;
            m_label.AutoSize = true;

            m_tooltip = new ToolTip();

            m_contextMenu = new ContextMenu();
            btnDelete = new MenuItem("Delete", Delete);
            m_contextMenu.MenuItems.Add(btnDelete);

            this.ContextMenu = m_contextMenu;

            this.AllowDrop = true;
            this.Dock = DockStyle.Fill;

            this.Controls.Add(m_label);
        }
Esempio n. 3
0
        public void AddLesson(Lesson doc)
        {
            var uuid = GetUUID();
            string json = JsonConvert.SerializeObject(doc);

            SendJSON(uuid, "PUT", json);
        }
Esempio n. 4
0
        public AddLessonCommand(Lesson lesson)
        {
            _lesson = lesson;

            LsDateTime = lesson.DateTime;
            LsComment = lesson.Comment;
        }
Esempio n. 5
0
        public void AddLesson(Lesson lesson)
        {
            var c = new MySqlCommand("insert into " + table +
                // " (faculty," +
                " (week," +
                "day," +
                "lesson_time," +
                "teacher," +
                "subject," +
                "room," +
                "st_group,"+
                "faculty" +
                ")" +
                " values (@week," +
                "@day," +
                "@time," +
                "@teacher," +
                "@subject," +
                "@room," +
                "@group," +
                "@faculty"+
                ")", Connection);
            c.Parameters.AddWithValue("@week", lesson.week);
            c.Parameters.AddWithValue("@day", lesson.day);
            c.Parameters.AddWithValue("@time", lesson.time);
            c.Parameters.AddWithValue("@teacher", lesson.teacher.Id);
            c.Parameters.AddWithValue("@subject", lesson.subject.Id);
            c.Parameters.AddWithValue("@room", lesson.room);
            c.Parameters.AddWithValue("@group", lesson.group.Id);
            c.Parameters.AddWithValue("@faculty", lesson.faculty.Id);

            c.ExecuteNonQuery();
        }
 internal void AddLesson(Lesson obj)
 {
     lock (padlock)
     {
         Lesson s = Lesson.CreateLesson(-1, obj.SubjectID, obj.Date);
         context.AddToLessons(s);
         context.SaveChanges();
     }
 }
 private void AddAverage()
 {
     float average = 0;
     average = (float)(Convert.ToInt32(textBoxG1.Text)+ Convert.ToInt32(textBoxG2.Text)+ Convert.ToInt32(textBoxG3.Text)) / 3;
     Lesson L2 = new Lesson(textBoxL1.Text, textBoxL2.Text, textBoxL3.Text, Convert.ToInt32(textBoxG1.Text), Convert.ToInt32(textBoxG2.Text), Convert.ToInt32(textBoxG3.Text));
     AverageStudent avst = new AverageStudent(textBoxName.Text.ToUpper(), textBoxSurname.Text.ToUpper(), textBoxDep.Text.ToUpper(), Convert.ToInt32(textBoxNo.Text),average,L2);
     AverageStudentList.Add(avst);
     ClearAllBoxes();
 }
Esempio n. 8
0
 public LessonVm(Lesson lesson)
 {
     Id = lesson.Id;
     DateTime = lesson.DateTime;
     IsTrial = lesson.IsTrial;
     Language = lesson.Language?.LanguageName;
     Comment = lesson.Comment;
     LessonStudent = lesson.Student;
     LessonTeacher = lesson.Teacher;
 }
Esempio n. 9
0
 public AddScene(Scene existingScene, Image image)
 {
     InitializeComponent();
     _lesson = existingScene.Lesson;
     sceneImage.Source = image.Source;
     scene = existingScene;
     SceneItems = new ObservableCollection<SceneItem>(existingScene.SceneItems.OrderBy(s=>s.Order).ToList());
     sceneImage.Tag = existingScene.ScenePicture;
     alreadyExist = true;
 }
Esempio n. 10
0
 public OperEvent SetLesson(Lesson l)
 {
     return new OperEvent(
         GoogleEvent, 
         l,
         m_parsed_title,
         m_parsed_students,
         m_parsed_teachers,
         m_parsed_comment);
 }
Esempio n. 11
0
 /// <summary>
 /// Fills lesson array
 /// </summary>
 static void FillLessonArray()
 {
     Lessons = new Lesson[10];
     Lessons[0] = new Lesson("Genetik Algoritmalar", 4);
     Lessons[1] = new Lesson("Bulanik Mantik", 4);
     Lessons[2] = new Lesson("Makine Ogrenmesi", 4);
     Lessons[3] = new Lesson("Ongoruye Dayali Analitik", 4);
     Lessons[4] = new Lesson("Zeki Sistemler", 4);
     Lessons[5] = new Lesson("Uzman Sistemler", 4);
     Lessons[6] = new Lesson("Dogal Dil Isleme", 3);
     Lessons[7] = new Lesson("Robotbilimde Yapay Zeka", 3);
     Lessons[8] = new Lesson("Veri Madenciligi", 3);
     Lessons[9] = new Lesson("Karinca Kolonisi Algoritmalari", 3);
 }
Esempio n. 12
0
        public IndexViewModel(Category[] categories, Lesson[] lessons)
        {
            CategoryList = new CategoryListViewModel(categories);
            LessonLists = new LessonListViewModel[categories.Length];

            for (int i = 0; i < categories.Length; i++)
            {
                LessonLists[i] = new LessonListViewModel
                (
                    lessons.Where(les => les.CategoryId == categories[i].Id).ToArray(),
                    categories[i].Name
                );
            }
        }
Esempio n. 13
0
        public void Lesson_Add()
        {
            Lesson lesson1 = new Lesson();
            Lesson lesson2 = new Lesson();
            Lesson lesson3 = new Lesson();

            Lecturer l1 = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
            Lecturer l2 = new Lecturer("John Smith", 32, "JS1", Color.Blue);
            Lecturer l3 = new Lecturer("Fred Flintstone", 50, "FF", Color.Blue);

            Module m1 = new Module("Programming", "Level 3", "PL3", Color.Blue);
            Module m2 = new Module("Networking", "Degree", "NET", Color.Blue);
            Module m3 = new Module("Technical Support", "Level 1", "Tech1", Color.Blue);

            Room r1 = new Room("Room1", "L1", Color.Blue, 20);
            Room r2 = new Room("Room2", "L2", Color.Blue, 19);
            Room r3 = new Room("Room3", "L3", Color.Blue, 17);

            Group g1 = new Group("Class1", "C1", Color.Blue, 20);
            Group g2 = new Group("Class2", "C2", Color.Blue, 20);
            Group g3 = new Group("Class3", "C3", Color.Blue, 20);

            lesson1.Lecturer = l1;
            lesson1.Module = m1;
            lesson1.Group = g1;
            lesson1.Room = r1;

            lesson2.Lecturer = l2;
            lesson2.Module = m2;
            lesson2.Group = g2;
            lesson2.Room = r2;

            lesson3.Lecturer = l3;
            lesson3.Module = m3;
            lesson3.Group = g3;
            lesson3.Room = r3;

            DataCollection.Instance.Add(lesson1);
            Assert.AreEqual<Lesson>(lesson1, DataCollection.Instance.Lessons[0], "Lesson1 not found at 0");

            //  Add another instance and check if this instance is in the second index (1)
            DataCollection.Instance.Add(lesson2);
            Assert.AreEqual<Lesson>(lesson2, DataCollection.Instance.Lessons[1], "Lesson2 not found at 1");

            //  Insert an instance into the second index (1) and check if the instance is at that index and the instance
            //    before has moved to the next index (2)
            DataCollection.Instance.Insert(lesson3, 1);
            Assert.AreEqual<Lesson>(lesson3, DataCollection.Instance.Lessons[1], "Lesson3 not found at 1");
            Assert.AreEqual<Lesson>(lesson2, DataCollection.Instance.Lessons[2], "Lesson2 not found at 2");
        }
        private void AddStudent()
        {
            try
            {
                Lesson L = new Lesson(textBoxL1.Text, textBoxL2.Text, textBoxL3.Text, Convert.ToInt32(textBoxG1.Text), Convert.ToInt32(textBoxG2.Text), Convert.ToInt32(textBoxG3.Text));
                Student st = new Student(textBoxName.Text.ToUpper(), textBoxSurname.Text.ToUpper(), textBoxDep.Text.ToUpper(),Convert.ToInt32(textBoxNo.Text), L);
                StudentList.Add(st);

                MessageBox.Show("Success!");

            }
            catch
            {
                ClearAllBoxes();
                MessageBox.Show("Error Please attention to the number of inputs");

            }
        }
Esempio n. 15
0
        private OperEvent(
            GCal.CalEvent ge, 
            Lesson l,
            string title,
            string[] students,
            string[] teachers,
            string comment)
        {
            GoogleEvent = ge;
            SuspectedLesson = l;
            m_parsed_title = title;
            m_parsed_students = students;
            m_parsed_teachers = teachers;
            m_parsed_comment = comment;

            Linked = false;

            SimilarityPlace = -1;
            SimilarityStart = -1;
            SimilarityDuration = -1;
            SimilarityTeacher = -1;
            SimilarityStudent = -1;
            SimilarityStatus = -1;
        }
Esempio n. 16
0
        public void Lesson_Clash_Test()
        {
            /*
             * Set instances: 2 Lessons with different data
             */
            Lesson lesson1 = new Lesson();
            Lesson lesson2 = new Lesson();

            Lecturer l1 = new Lecturer("Joe Bloggs", 14, "JB", Color.Blue);
            Lecturer l2 = new Lecturer("John Smith", 32, "JS1", Color.Blue);

            Module m1 = new Module("Programming", "Level 3", "PL3", Color.Blue);
            Module m2 = new Module("Networking", "Degree", "NET", Color.Blue);

            Room r1 = new Room("Room1", "L1", Color.Blue, 20);
            Room r2 = new Room("Room2", "L2", Color.Blue, 19);

            Group g1 = new Group("Class1", "C1", Color.Blue, 20);
            Group g2 = new Group("Class2", "C2", Color.Blue, 20);

            /*
             * Set so that each Lesson has different data, except the same time and day
             */
            lesson1.Lecturer = l1;
            lesson1.Module = m1;
            lesson1.Group = g1;
            lesson1.Room = r1;

            lesson2.Lecturer = l2;
            lesson2.Module = m2;
            lesson2.Group = g2;
            lesson2.Room = r2;

            lesson1.Time = 1;
            lesson1.Day = 1;

            lesson2.Time = 1;
            lesson2.Day = 1;

            DataCollection.Instance.Add(lesson1);
            DataCollection.Instance.Add(lesson2);

            /*
             *  Test if there is NO clash.
             *  Each lesson is different.
             */
            Assert.IsFalse(DataCollection.Instance.DoesLessonClash(lesson1), "Detected a clash when values should not");

            /*
             *  Set lesson2 to have the same Room as lesson1.
             *  Test for clash: Same Room holding different Lessons.
             */
            lesson2.Room = r1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Room when it should");
            lesson2.Room = r2;

            /*
             *  Set lesson2 to have the same Lecturer as lesson1.
             *  Test for clash: Same Lecturer at different Lessons.
             */
            lesson2.Lecturer = l1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Lecturer when it should");
            lesson2.Lecturer = l2;

            /*
             *  Set lesson2 to have the same Group as lesson1.
             *  Test for clash: Same Group at different Lessons
             */
            lesson2.Group = g1;
            Assert.IsTrue(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Group when it should");
            lesson2.Group = g2;

            /*
             *  Set lesson2 to have the same Module as lesson1.
             *  Test for NO clash: Same Module at different Lessons.
             */
            lesson2.Module = m1;
            Assert.IsFalse(DataCollection.Instance.DoesLessonClash(lesson1), "Did not detect a clash with the same Module when it should");
            lesson2.Module = m2;
        }
Esempio n. 17
0
 public LessonTypeEl(Lesson type)
 {
     Lesson = type;
 }
Esempio n. 18
0
 public void AdicionarAula(Lesson aula) => _aulas.Add(aula);
Esempio n. 19
0
    public static void SaveLesson(List<int> studentids, List<int> subjectids, string date, string lessonTitle, string lessonDescription, int timeSpent)
    {
        //int time = 0;
        //bool timeValid = Int32.TryParse(timeSpent, out time);

        //if (!timeValid)
        //{
        //    throw new ArgumentException("timeSpent must be a valid number of minutes");
        //}

        //// Verify the currentuser is a teacher for this school
        //var ua = new UserAccessor(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
        //var recordaccessor = new RecordAccessor(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
        //var subjectaccessor = new SubjectAccessor(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
        //var childaccessor = new ChildAccessor(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);

        var mu = Membership.GetUser();

        if (mu != null)
        {
            using (var db = ServiceEngine.Instance.IoC.Resolve<IEntityStore>())
            {
                var user = db.Query<User>().GetUserByLogin(mu.UserName);

                if (user.IsTeacher)
                {
                    // Get the students involved
                    var students = db.Query<Student>().GetStudentsByIds(studentids);

                    // Get the subjects involved
                    var subjects = db.Query<Subject>().GetSubjectsByIds(subjectids);

                    // Get the date
                    var recordDate = DateTime.Parse(date);

                    // Get the details
                    var lesson = new Lesson
                                     {
                                         LessonDate = recordDate,
                                         LessonTitle = lessonTitle,
                                         Notes = lessonDescription,
                                         TimeSpent = timeSpent,
                                         RecordedBy = user
                                     };

                    foreach (var subject in subjects)
                    {
                        lesson.Subjects.Add(subject);
                    }

                    foreach (var student in students)
                    {
                        lesson.Students.Add(student);
                    }

                    db.AddEntity(lesson);
                    db.SaveChanges();
                }
            }
        }
    }
Esempio n. 20
0
 public void UpdateLesson(Lesson lesson)
 {
     _context.Lesson.Update(lesson);
     _context.SaveChanges();
 }
Esempio n. 21
0
 public void CreateLesson(Lesson lesson)
 {
     _context.Lesson.Add(lesson);
     _context.SaveChanges();
 }
Esempio n. 22
0
        public static void Seed(ApplicationDbContext dBContext)
        {
            if ((dBContext.GetService <IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
            {
                return;
            }

            dBContext.Database.Migrate();

            if (dBContext.Applicants.Any())
            {
                return;
            }

            List <Technology> technologiesList = new List <Technology>()
            {
                new Technology()
                {
                    Name = "Programming fundamentals-Evening hours"
                },
                new Technology()
                {
                    Name = "Programming fundamentals-Afternoon hour"
                },
                new Technology()
                {
                    Name = "Object-oriented programming with C# and .NET Framework"
                },
                new Technology()
                {
                    Name = "ASP MVC back-end programming"
                },
                new Technology()
                {
                    Name = "Introduction to JavaScript"
                },
                new Technology()
                {
                    Name = "Advanced JavaScript and JS Frameworks"
                },
                new Technology()
                {
                    Name = "QA Fundamentals"
                },
                new Technology()
                {
                    Name = "UI/UX Design"
                },
                new Technology()
                {
                    Name = "Introduction to Python"
                },
                new Technology()
                {
                    Name = "Network administration"
                },
            };

            dBContext.Technologies.AddRange(technologiesList);

            Teacher teacher1 = new Teacher()
            {
                FirstName = "Levon",
                LastName  = "Hovhanisyan",
                Phone     = "099999999",
                Email     = "*****@*****.**"
            };

            dBContext.Teachers.Add(teacher1);

            Teacher teacher2 = new Teacher()
            {
                FirstName = "Arayik",
                LastName  = "Melqonyan",
                Phone     = "077777777",
                Email     = "*****@*****.**"
            };

            dBContext.Teachers.Add(teacher2);

            Lesson lesson1 = new Lesson()
            {
                Teacher      = teacher1,
                Technology   = technologiesList[3],
                StartingDate = DateTime.Now,
                EndingDate   = DateTime.Now,
            };

            dBContext.Lessons.Add(lesson1);

            Lesson lesson2 = new Lesson()
            {
                Teacher      = teacher2,
                Technology   = technologiesList[2],
                StartingDate = DateTime.Now,
                EndingDate   = DateTime.Now,
            };

            dBContext.Lessons.Add(lesson2);

            Applicant applicant1 = new Applicant()
            {
                FirstName   = "On",
                LastName    = "Asoyan",
                Phone1      = "+37477617517",
                Email       = "*****@*****.**",
                Description = "aklajsklajlkjl",
                Date        = new DateTime(2018, 10, 12),
                Lesson      = lesson1,
            };

            dBContext.Applicants.Add(applicant1);

            Applicant applicant2 = new Applicant()
            {
                FirstName   = "Suren",
                LastName    = "Avagyan",
                Phone1      = "+37498252525",
                Email       = "*****@*****.**",
                Description = "Suro",
                Date        = new DateTime(2018, 10, 12),
                Lesson      = lesson2,
            };

            dBContext.Applicants.Add(applicant2);

            dBContext.SaveChanges();
        }
Esempio n. 23
0
 public static Interval <DateTime> GetInterval(this Lesson lesson) => new Interval <DateTime>(lesson.Start, lesson.Start.AddMinutes(lesson.Duration));
Esempio n. 24
0
 public IActionResult LessonsAdd(Lesson lesson)
 {
     _context.Lessons.Add(lesson);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Esempio n. 25
0
 public void Update(Lesson item)
 {
     Database.Lessons.Update(item);
 }
Esempio n. 26
0
        void PopulateLessonProgPrice(Lesson l, string prog)
        {
            foreach (Student stud in SpecificStudent(l.Student1))
            {
                for (int i = 1; i <= 3; i++)
                {
                    if (!IsStringEmpty(stud.Program(i)))
                    {
                        l.Program = SetComboByValue(cbLessonProg, stud.Program(i));

                        string spr = stud.Price(i);
                        if (IsStringEmpty(spr))
                            spr = GetProgramPrice(l.Program);

                        l.Price = spr;
                        return;
                    }
                }
                if (!IsStringEmpty(prog))
                {
                    string spr = GetProgramPrice(prog);
                    l.Price = spr;
                }
            }
        }
Esempio n. 27
0
 public void Create(Lesson item)
 {
     Database.Lessons.Create(item);
 }
Esempio n. 28
0
        public LocalController()
        {
            Lesson lesson1 = new Lesson()
            {
                Name            = "ООП",
                Type            = "лекция",
                Classroom       = "A455",
                TeacherName     = "Бимурзаев",
                TeacherPosition = "доцент"
            };
            Lesson lesson2 = new Lesson()
            {
                Name            = "Web",
                Type            = "лаб. работа",
                Classroom       = "Б128",
                TeacherName     = "Бидахмет",
                TeacherPosition = "PHD"
            };
            List <Day> days = new List <Day>()
            {
                new Day()
                {
                    Name       = "Понедельник",
                    TimeRanges = new List <TimeRange>()
                    {
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        },
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        },
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        }
                    }
                },
                new Day()
                {
                    Name       = "Вторник",
                    TimeRanges = new List <TimeRange>()
                    {
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        },
                        new TimeRange()
                        {
                            Index       = 1,
                            StartTime   = "09:30",
                            EndTime     = "10:30",
                            UnionLesson = lesson1
                        },
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        }
                    }
                },
                new Day()
                {
                    Name       = "Четверг",
                    TimeRanges = new List <TimeRange>()
                    {
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1,
                            Subgroup2 = lesson2
                        },
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup2 = lesson2
                        },
                        new TimeRange()
                        {
                            Index     = 1,
                            StartTime = "09:30",
                            EndTime   = "10:30",
                            Subgroup1 = lesson1
                        }
                    }
                },
            };

            schedules.Add(new Schedule()
            {
                Group    = groups[0],
                Days     = days,
                Facility = facilities[0]
            });
            schedules.Add(new Schedule()
            {
                Group    = groups[1],
                Days     = days,
                Facility = facilities[1]
            });
        }
Esempio n. 29
0
 public ActionResult Create(Lesson obj)
 {
     UniversityLiveModel.Instance.AddLesson(obj);
     return RedirectToAction("Index");
 }
Esempio n. 30
0
        private async void btn_Done_AddLesson_Click(object sender, RoutedEventArgs e)
        {
            bool       cont                = true;
            int        daynumber           = cmb_Day_AddLesson.SelectedIndex;
            DayOfWeek  day                 = DayOfWeek.Monday;
            bool       day_complete        = true;
            LessonTime lessontime          = LessonTimeManager.GetLessonTimes()[0];
            bool       lessontime_complete = true;
            Subject    subject             = SubjectManager.GetSubjects()[0];
            bool       subject_complete    = true;

            if (daynumber == 0)
            {
                day = DayOfWeek.Monday;
            }
            else if (daynumber == 1)
            {
                day = DayOfWeek.Tuesday;
            }
            else if (daynumber == 2)
            {
                day = DayOfWeek.Wednesday;
            }
            else if (daynumber == 3)
            {
                day = DayOfWeek.Thursday;
            }
            else if (daynumber == 4)
            {
                day = DayOfWeek.Friday;
            }
            else
            {
                day_complete = false;
            }

            if (cmb_LessonTime_AddLesson.SelectedIndex != -1)
            {
                lessontime = (LessonTime)cmb_LessonTime_AddLesson.SelectedItem;
            }
            else
            {
                lessontime_complete = false;
            }

            if (cmb_Subject_AddLesson.SelectedIndex != -1)
            {
                subject = (Subject)cmb_Subject_AddLesson.SelectedItem;
            }
            else
            {
                subject_complete = false;
            }

            if (day_complete == false || lessontime_complete == false || subject_complete == false)
            {
                LessonManager.not_completed_dialog();
            }
            else
            {
                if (LessonManager.GetLesson(day, lessontime) != null)
                {
                    ContentDialogResult result = await LessonManager.already_exists_dialog();

                    if (result == ContentDialogResult.Secondary)
                    {
                        edit_lesson = LessonManager.GetLesson(day, lessontime);
                    }
                    else
                    {
                        cont = false;
                    }
                }
                if (cont)
                {
                    if (edit_lesson != null)
                    {
                        LessonManager.DeleteLesson(edit_lesson.day, edit_lesson.lesson_time);
                    }
                    LessonManager.AddLesson(new Lesson {
                        day = day, lesson_time = lessontime, subject_id = subject.id
                    });
                }
            }
            if (cont)
            {
                Frame.GoBack();
            }
        }
Esempio n. 31
0
        private void CloneLessons(Lesson lbase, List<DateTime> dates)
        {
            StartBulkEditOperation(Modes.Lessons);

            foreach (DateTime dt in dates)
            {
                Lesson l;
                buttonAdd_Click(null, null);
                l = lessonList.Current as Lesson;
                lbase.CloneValuesTo(l);
                l.Day = dt.ToShortDateString();
            }

            CompleteBulkEditOperation();
        }
Esempio n. 32
0
        public IHttpActionResult AddCousre(JObject Data)
        {
            try
            {
                string             token = Request.Headers.GetValues("token").FirstOrDefault().ToString();
                AddLessonItemModel item  = JsonConvert.DeserializeObject <AddLessonItemModel>(Data.ToString());

                if (token != null && token.Trim() != string.Empty)
                {
                    var result = this.CheckToken(token);
                    if (result.Status == 0)
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        List <UnitDetailModel> ListData = new List <UnitDetailModel>();
                        using (var con = new ENGSMARTEntities())
                        {
                            Lesson lesson = new Lesson()
                            {
                                Description = item.Description,
                                Image       = item.Image,
                                Link        = item.Link,
                                Order       = item.Order,
                                Title       = item.Title
                            };
                            con.Lessons.Add(lesson);
                            con.SaveChanges();

                            ResultModal resultLesson = new ResultModal()
                            {
                                Status = 1,
                                Code   = 200,
                                Mess   = "Thêm mới bài học thành công",
                                Data   = lesson
                            };
                            return(Ok(resultLesson));
                        }
                    }
                }
                else
                {
                    ResultModal result = new ResultModal()
                    {
                        Status = 0,
                        Code   = 403,
                        Mess   = "Phiên đăng nhập hết hạn",
                        Data   = null,
                        Token  = ""
                    };
                    return(Ok(result));
                }
            }
            catch (Exception ex)
            {
                ResultModal result = new ResultModal()
                {
                    Status = 0,
                    Code   = 400,
                    Mess   = ex.Message,
                    Data   = null,
                };
                return(Ok(result));
            }
        }
Esempio n. 33
0
 public CreateLessonRequest(Guid sectionId, Guid courseId, Lesson lesson)
 {
     SectionId = sectionId;
     CourseId  = courseId;
     Lesson    = lesson;
 }
Esempio n. 34
0
 public string Add(Lesson item)
 {
     return(_lessonsDao.Add(item));
 }
Esempio n. 35
0
        protected override void Seed(DAL.GeneralContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            Group group1 = new Group()
            {
                CourseNumber = 2,
                GroupNumber  = 216,
                Lessons      = new List <Lesson>()
            };
            Group group2 = new Group()
            {
                CourseNumber = 3,
                GroupNumber  = 313,
                Lessons      = new List <Lesson>()
            };

            Teacher teacher1 = new Teacher()
            {
                Name    = "Ivan",
                Surname = "Ivanov",
                Post    = "Teacher",
                Lessons = new List <Lesson>()
            };
            Teacher teacher2 = new Teacher()
            {
                Name    = "Petr",
                Surname = "Petrov",
                Post    = "Teacher",
                Lessons = new List <Lesson>()
            };

            Lesson lesson1 = new Lesson()
            {
                WeekNumber   = Week.SecondWeek,
                DayOfTheWeek = Day.Saturday,
                LessonNumber = 1,
                LessonName   = "Programming",
                Group        = group1,
                Teacher      = teacher1
            };
            Lesson lesson2 = new Lesson()
            {
                WeekNumber   = Week.FirstWeek,
                DayOfTheWeek = Day.Tuesday,
                LessonNumber = 4,
                LessonName   = "Philosophy",
                Group        = group2,
                Teacher      = teacher2
            };

            group1.Lessons.Add(lesson1);
            group2.Lessons.Add(lesson2);
            teacher1.Lessons.Add(lesson1);
            teacher2.Lessons.Add(lesson2);


            context.Lessons.AddOrUpdate(lesson1);
            context.Lessons.AddOrUpdate(lesson2);
            context.Teachers.AddOrUpdate(teacher1);
            context.Teachers.AddOrUpdate(teacher2);
            context.Groups.AddOrUpdate(group1);
            context.Groups.AddOrUpdate(group2);

            context.SaveChanges();
        }
Esempio n. 36
0
 public void AddLesson(Course c, Lesson l)
 {
     Lessons.Add(l);
     c.Lessons.Add(l);
     SaveChanges();
 }
Esempio n. 37
0
        public void Lesson_Constructor()
        {
            Lesson lesson = new Lesson();
            Assert.AreEqual(null, lesson.Lecturer, "Failed to match Lecturer after Construtor");
            Assert.AreEqual(null, lesson.Module, "Failed to match Module after Construtor");
            Assert.AreEqual(null, lesson.Room, "Failed to match Room after Construtor");
            Assert.AreEqual(null, lesson.Group, "Failed to match Group after Construtor");

            Lecturer lect = new Lecturer("Fred Flintstone", 12, "FF", Color.White);
            lesson.Lecturer = lect;
            Assert.AreEqual(lect, lesson.Lecturer, "Lecturer Property failed");

            Module mod = new Module("Software Engineering", "Degree", "SED", Color.White);
            lesson.Module = mod;
            Assert.AreEqual(mod, lesson.Module, "Module Property failed");

            Room room = new Room("Y007", "007", Color.Bisque, 30);
            lesson.Room = room;
            Assert.AreEqual(room, lesson.Room, "Room Property failed");

            Group grp = new Group("Group A", "GrA", Color.DarkSeaGreen, 24);
            lesson.Group = grp;
            Assert.AreEqual(grp, lesson.Group, "Group Property failed");
        }
Esempio n. 38
0
        public Lesson GetLessonById(int?id)
        {
            Lesson lesson = Lessons.Include(l => l.AbsenceRegistrations).FirstOrDefault(l => l.Id == id);

            return(lesson);
        }
Esempio n. 39
0
 public void AddAbsenceRegistration(Lesson l, Student s)
 {
     AbsenceRegistrations.Add(new AbsenceRegistration(s, l));
     SaveChanges();
 }
Esempio n. 40
0
        public void InsertTest() {
            var schoolDay = new SchoolDay();

            // first
            int count = schoolDay.Count;
            DateTime start = schoolDay.Start;
            Lesson lesson1 = new Lesson(schoolDay.Start);
            schoolDay.Insert(0, lesson1);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[0], lesson1);
            Assert.AreEqual(schoolDay.First, lesson1);
            Assert.AreEqual(schoolDay.Start, start.Subtract(lesson1.Duration));
            Assert.AreEqual(lesson1.Start, schoolDay.Start);
            Assert.AreEqual(lesson1.End, start);
            Assert.AreEqual(lesson1.Duration, Lesson.LessonDuration);

            // inside
            count = schoolDay.Count;
            start = schoolDay.Start;
            ShortBreak shortBreak1 = new ShortBreak(schoolDay.Start);
            schoolDay.Insert(1, shortBreak1);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[1], shortBreak1);
            Assert.AreEqual(schoolDay.First, lesson1);
            Assert.AreEqual(schoolDay.Start, start);
            Assert.AreEqual(shortBreak1.Start, schoolDay.Start.Add(lesson1.Duration));
            Assert.AreEqual(shortBreak1.Duration, ShortBreak.ShortBreakDuration);

            // last
            count = schoolDay.Count;
            DateTime end = schoolDay.End;
            ShortBreak shortBreak2 = new ShortBreak(schoolDay.Start);
            schoolDay.Insert(schoolDay.Count, shortBreak2);
            Assert.AreEqual(schoolDay.Count, count + 1);
            Assert.AreEqual(schoolDay[count], shortBreak2);
            Assert.AreEqual(schoolDay.Last, shortBreak2);
            Assert.AreEqual(schoolDay.End, shortBreak2.End);
            Assert.AreEqual(shortBreak2.Start, end);
            Assert.AreEqual(shortBreak2.Duration, ShortBreak.ShortBreakDuration);
        }
Esempio n. 41
0
        public void FillLessonFromCalendar(Lesson l)
        {
            int slot = SlotFromStringTime(lbReconcileFrom.Text, false);
            cbLessonStart.SelectedIndex = slot;
            l.Start = m_enumTimeSlot[slot];

            slot = SlotFromStringTime(lbReconcileTo.Text, true);
            cbLessonEnd.SelectedIndex = slot;
            l.End = m_enumTimeSlot[slot];

            DateTime dt = DateTime.Now;
            DateTime.TryParse(lbReconcileDate.Text, out dt);
            monthCalLessonDate.SetDate(dt);
            l.Day = dt.ToShortDateString();

            string s = lbReconcileDescription.Text;
            tbLessonComment.Text = s;
            l.Comments = s;
            bool cancelled = !IsStringEmpty(s) &&
                             (s.ToLower().IndexOf("cancel") >= 0);

            l.Room = SetComboByInitial(cbLessonRoom, lbReconcileLocation.Text);

            l.GoogleId = lbReconcileGoogleCalId.Text;

            l.State = SetComboByValue(cbLessonState, 
                            (cancelled ? m_enumState[(int)LessonStates.Cancelled] :
                                         m_enumState[(int)LessonStates.Planned]) );

            string geTitle, geComment;
            string[] geStudents, geTeachers;

            ParseEventDescription( lbReconcileDescription.Text,
                out geTitle, out geStudents, out geTeachers, out geComment);

            for (int i = 0; i < 2 && i < geTeachers.Length; i++)
            {
                string str = ExtractTeacher(geTeachers[i], i+1);
                if (!IsStringEmpty(str))
                    l.SetTeacher(SetComboByValue(LessonTeacherComboBox(i+1), str), i+1);
            }

            for (int i = 0; i < 10 && i < geStudents.Length; i++)
            {
                string str = ExtractStudent(geStudents[i], i+1);
                if (!IsStringEmpty(str))
                    l.SetStudent(SetComboByValue(LessonStudentComboBox(i+1), str), i+1);
            }
        }
 protected string GetLessonTitle(Lesson lesson)
 {
     return lesson.Date.ToString("dd/MM");
 }
Esempio n. 43
0
 public void Add(Lesson entity)
 {
     _lessonDAL.Add(entity);
 }
Esempio n. 44
0
 private void B_View_Click(object sender, EventArgs e)
 {
     _lesson = _todaysLessons[LB_Lessons.SelectedIndex];
 }
Esempio n. 45
0
 public EditLessonCommand(Lesson lesson)
 {
     _lesson = lesson;
 }
Esempio n. 46
0
 public void Delete(Lesson entity)
 {
     entity.IsActive = false;
     _lessonDAL.Update(entity);
 }
Esempio n. 47
0
File: UnitTest1.cs Progetto: ghy/SMS
        public void DataInit()
        {
            using (var _session = HibernateUtils.SessionFactory.OpenSession())
            {
                try
                {
                    _session.Transaction.Begin();
                    Administrator adm = new Administrator()
                    {
                        Account = "admin",
                        Password = "******",
                        Status = Enum.UserStatus.Enable,
                        Role = Enum.Role.Teacher,
                        Name = "管理员",
                        CreationDateTime = DateTime.Now,
                        Gender = Enum.Gender.Male
                    };
                    _session.Save(adm);

                    var t1 = new Teacher()
                    {
                        Account = "115026672",
                        Password = "******",
                        Status = Enum.UserStatus.Enable,
                        Name = "LK-楽瞳",
                        Role = Role.Teacher,
                        CreationDateTime = DateTime.Now,
                        Gender = Gender.Male
                    };
                    _session.Save(t1);

                    var cls1 = new Class()
                    {

                        CreationDateTime = DateTime.Now,
                        Creator = adm,
                        Name = "标日初级3班",
                        Teacher = t1
                    };
                    _session.Save(cls1);

                    #region 学生
                    var students = new[] {
                        new []{"1","LK-当   初","383953572","0"},
                        new []{"2","LK-仙   桃","124757433","0"},
                        new []{"3","LK-Smile","1339978253","1"},
                        new []{"4","LK-额   旭","391332035","0"},
                        new []{"5","LK-告诉我","308344711","1"},
                        new []{"6","LK-乐   园","860828579","1"},
                    };

                    #region MyRegion
                    foreach (var student in students)
                    {
                        var no = student[0];
                        var name = student[1];
                        var account = student[2];
                        var gender = Convert.ToInt32(student[3]);
                        _session.Save(new Student()
                        {
                            No = Convert.ToInt32(no),
                            Name = name,
                            Account = account,
                            Gender = (Gender)gender,
                            Password = "******",
                            Role = Role.Student,
                            CreationDateTime = DateTime.Now,
                            Class = cls1,
                            Creator = adm,
                            Email = account + "@qq.com",
                            Status = UserStatus.Enable
                        });
                    }
                    #endregion

                    #endregion

                    #region Course
                    DateTime date = new DateTime(2011, 11, 25);
                    int i = 0;
                    while (i < 23)
                    {

                        #region c1

                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }

                        var c1 = new Course()
                        {
                            Name = String.Format("单词,语法(第{0}课)", ++i),
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };

                        _session.Save(c1);

                        var lesson1 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c1,
                            TakeClassDate = date,
                            Name = c1.Name,

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson1);
                        #endregion

                        #region c2
                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }

                        var c2 = new Course()
                        {
                            Name = "复习,会话",
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };
                        _session.Save(c2);

                        var lesson2 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c2,
                            Name = c2.Name,
                            TakeClassDate = date

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson2);
                        #endregion

                        #region c3
                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }

                        var c3 = new Course()
                        {
                            Name = String.Format("单词,语法(第{0}课)", ++i),
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };
                        _session.Save(c3);

                        var lesson3 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c3,
                            Name = c3.Name,
                            TakeClassDate = date

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson3);

                        #endregion

                        #region c4
                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }

                        var c4 = new Course()
                        {
                            Name = "复习,会话",
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };
                        _session.Save(c4);

                        var lesson4 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c4,
                            Name = c4.Name,
                            TakeClassDate = date

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson4);

                        #endregion

                        #region c5

                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }
                        var c5 = new Course()
                        {
                            Name = "课后练习1,练习2",
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };
                        _session.Save(c5);

                        var lesson5 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c5,
                            Name = c5.Name,
                            TakeClassDate = date

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson5);

                        #endregion

                        #region c6
                        if (date.DayOfWeek == DayOfWeek.Sunday)
                        {
                            date = date.AddDays(1);
                        }

                        var c6 = new Course()
                        {
                            Name = "同步练习册讲解(包含听力)",
                            SchoolBook = SchoolBook.StandardJapaneseFirst
                        };
                        _session.Save(c6);

                        var lesson6 = new Lesson()
                        {

                            Class = cls1,
                            CreationDateTime = DateTime.Now,
                            Teacher = cls1.Teacher,
                            LessonType = LessonType.Evening,
                            Creator = adm,
                            Course = c6,
                            Name = c6.Name,
                            TakeClassDate = date

                        };
                        date = date.AddDays(1);
                        _session.Save(lesson6);
                        #endregion
                    }

                    #endregion

                    _session.Transaction.Commit();
                }
                catch (Exception e)
                {
                    var msg = e.Message;
                    _session.Transaction.Rollback();
                    throw e;

                }
            }
        }
Esempio n. 48
0
 public void Update(Lesson entity)
 {
     _lessonDAL.Update(entity);
 }
Esempio n. 49
0
        // GET: Person/Details/5
        public async Task <ActionResult> Details(int id)
        {
            string head = User.Identity.GetUserId();

            Person student = context.People
                             .Include("Location")
                             .Where(per => per.ApplicationId == head)
                             .FirstOrDefault()
            ;

            //this is the teacher!
            PersonAndLocationViewModel personLocationDetails = new PersonAndLocationViewModel();

            personLocationDetails.person = context.People
                                           .Include("Location")
                                           .Where(p => p.PersonId == id)
                                           .Single();
            //this is the teacher's location!
            personLocationDetails.location = context.Locations.Where(l => l.LocationId == personLocationDetails.person.LocationId).Single();

            personLocationDetails.studentLocationId = student.LocationId;
            personLocationDetails.studentId         = student.PersonId;

            TeacherPreference tpreffer = context.Preferences.Where(pref => pref.teacherId == id).FirstOrDefault();

            int           range     = tpreffer.maxDistance;
            RadiusOptions type      = tpreffer.distanceType;
            decimal       increment = tpreffer.incrementalCost;

            decimal inHomeCost;

            //student.PersonId is still ok to use here!
            //string userId = User.Identity.GetUserId();
            //Person studentA = context.People.Where(peop => peop.ApplicationId == userId).FirstOrDefault();
            //int tempDistance = await Service_Classes.DistanceMatrix.GetTravelInfo(studentA, personLocationDetails.person);
            ////int tempDuration = await Service_Classes.DistanceMatrix.GetTravelInfo(student, personLocationDetails.person);
            ////inHomeCost = tpreffer.PerHourRate + (tpreffer.incrementalCost * tempDuration);


            ////personLocationDetails.outOfRange = tempDuration > tpreffer.maxDistance ? true : false;
            ////personLocationDetails.outOfRangeNum = personLocationDetails.outOfRange ? 1 : 0;
            ////personLocationDetails.inHomeCost = inHomeCost;
            ////personLocationDetails.studioCost = tpreffer.PerHourRate;


            var tempTeacher = context.Preferences.Where(p => p.teacherId == personLocationDetails.person.PersonId).SingleOrDefault();//tlc

            //this is the teacher's preferences
            var teacherPreferences = context.Preferences.Where(p => p.teacherId == personLocationDetails.person.PersonId).SingleOrDefault();//tlc

            if (teacherPreferences != null)
            {
                if (teacherPreferences.distanceType == RadiusOptions.Miles)
                {
                    string userId = User.Identity.GetUserId();

                    double teacherPreferenceRadius = teacherPreferences.maxDistance;                         //tlc
                    ViewBag.radius = teacherPreferenceRadius * Service_Classes.DistanceMatrix.metersToMiles; //tlc

                    var tempStudent = context.People.Include("Location").Where(p => p.ApplicationId == userId).SingleOrDefault();

                    if (tempStudent.PersonId != teacherPreferences.teacherId)
                    {
                        Lesson tempLesson = new Lesson();
                        tempLesson.Teacher    = context.People.Where(t => t.PersonId == teacherPreferences.teacherId).SingleOrDefault();
                        tempLesson.Student    = tempStudent;
                        tempLesson.Location   = tempStudent.Location;
                        tempLesson.LocationId = tempStudent.LocationId;
                        tempLesson            = await Service_Classes.DistanceMatrix.GetTravelInfo(tempLesson);

                        //ViewBag.lessonPrice =
                        ViewBag.outOfRange = teacherPreferences.maxDistance > tempLesson.travelDuration;
                    }
                }
                else if (tempTeacher.distanceType == RadiusOptions.Minutes)
                {
                    ViewBag.radius = teacherPreferences.maxDistance;
                }
            }



            return(View(personLocationDetails));
        }
Esempio n. 50
0
 public void addLesson(Lesson NewLesson)
 {
     this.Lessons.Add(NewLesson);
 }
Esempio n. 51
0
        private static void SetupPseudoData()
        {
            WriteSetupMessage("Populating tables");
            //News
            WriteSetupMessageIndent("Creating news");
            Creator.CreateNews(Person.GetByID(1) as Secretary, "Informant Stuff", "Vi startede med at få informanten til at fortælle om hvordan hendes hverdag var, herefter spurgte vi ind til til de områder der blev nævnt som vi følte var relevante for et nyt system. Gennem interviewet kom vi frem til at informanten primært bruger skemaet, tjek af fravær, og aflevering af opgaver. Informanten bruger skemaet til at tjekke lokale og f*g samt lektier. Derudover bruger informanten en funktion til at aflevere sine opgaver, hvor hun fortalte at det ville være hjælpsomt, hvis der kom en bekræftelse på at opgaverne er afleveret. Derudover fortalte hun, at systemet ikke skal logge af, således at den forbliver logget ind.");
            Creator.CreateNews(Person.GetByID(1) as Secretary, "Ændring af elev login.", "Der er sket en fejl i opretning af jeres elev logins, så jeres login virker ikke d. 3 Feb 2017, da jeres login skal opdateres.");
            Creator.CreateNews(Person.GetByID(1) as Secretary, "Der er ikke lektiecafé i matematik i dag torsdag d. 12/1-17 kl. 13.45-16.30.", "");
            Creator.CreateNews(Person.GetByID(1) as Secretary, "Administrationen i Aalborg afd.lukker kl. 13.30 fredag den 13.1.17", "");
            Creator.CreateNews(Person.GetByID(1) as Secretary, "Velkommen til vores afdeling i Aars!", "Her underviser vi både i HF enkeltfag, AVU (Almen voksenuddannelse), FVU(forberedende voksenuddannelse) og OBU(ordblindeundervisning).Vil du vide mere om vores uddannelser finder du dem på forsiden af hjemmesiden eller ved hjælp af den farvede bjælke herover for. Du kan ligeledes finder oplysninger om vores personale - dette finder du i menuen til venstre. Vi glæder os til at byde dig velkommen som kursist i vores flotte nye lokaler.");

            // Students
            WriteSetupMessageIndent("Creating students");
            var student01 = Student.New("Helle", "helle", "1234");
            var student02 = Student.New("Gunner Ebbesen", "gunnerebbesen", "1234");
            var student03 = Student.New("Kent Poulsen", "kentpoulsen", "1234");
            var student04 = Student.New("Bertel Greve", "bertelgreve", "1234");
            var student05 = Student.New("Esben Enevoldsen", "esbenenevoldsen", "1234");
            var student06 = Student.New("Olga Jansen", "olgajansen", "1234");
            var student07 = Student.New("Sanne Kruse", "sannekruse", "1234");
            var student08 = Student.New("Maybritt Erichsen", "maybritterichsen", "1234");
            var student09 = Student.New("Stine Haagensen", "stinehaagensen", "1234");
            var student10 = Student.New("Emilie Danielsen", "emiliedanielsen", "1234");
            var students  = Group(student01, student02, student03, student04, student05, student06, student07, student08, student09, student10);

            // Teachers
            WriteSetupMessageIndent("Creating teachers");
            var teacher01 = Teacher.New("Henry Hoj", "henryhoj", "1234");
            var teacher02 = Teacher.New("Steffen Johansen", "steffenjohansen", "1234");
            var teacher03 = Teacher.New("Palle Jacobsen", "pallejacobsen", "1234");
            var teacher04 = Teacher.New("Bendt Morch", "bendtmorch", "1234");
            var teacher05 = Teacher.New("Alex Larsen", "alexlarsen", "1234");
            var teacher06 = Teacher.New("Christa Hoj", "christahoj", "1234");
            var teacher07 = Teacher.New("Lykke Pallesen", "lykkepallesen", "1234");
            var teacher08 = Teacher.New("Hjordis Frandsen", "hjordisfrandsen", "1234");
            var teacher09 = Teacher.New("Lilli Rask", "lillirask", "1234");
            var teacher10 = Teacher.New("Hjordis Villumsen", "hjordisvillumsen", "1234");
            var teachers  = Group(teacher01, teacher02, teacher03, teacher04, teacher05, teacher06, teacher07, teacher08, teacher09, teacher10);

            // Rooms
            WriteSetupMessageIndent("Creating rooms");
            var room01 = Room.New("R301");
            var room02 = Room.New("R302");
            var room03 = Room.New("R303");
            var room04 = Room.New("R304");
            var room05 = Room.New("R305");
            var room06 = Room.New("A319");
            var room07 = Room.New("A320");
            var room08 = Room.New("A321");
            var room09 = Room.New("A322");
            var room10 = Room.New("A323");
            var rooms  = Group(room01, room02, room03, room04, room05, room06, room07, room08, room09, room10);

            // Messages
            WriteSetupMessageIndent("Creating messages");
            var message01 = Message.New(student01, "Hjælp til dansk", "Tekst", Group <Person>(student02), Group <string>());
            var message02 = Message.New(student01, "Angående aflevering", "Tekst", Group <Person>(student03, student04, teacher01, teacher02), Group <string>());
            var message03 = Message.New(student01, "Kemi spørgsmål", "Tekst", Group <Person>(student05, student06, teacher03, teacher04), Group <string>());
            var message04 = Message.New(student01, "Idrætsdag", "Tekst", Group <Person>(student07, student08, teacher05, teacher06), Group <string>());
            var message05 = Message.New(student01, "Nye åbningstider ved studievejleder", "Tekst", Group <Person>(student09, student10, teacher07, teacher08), Group <string>());
            var message06 = Message.New(student02, "Åbent hus", "Tekst", Group <Person>(student01, teacher09), Group <string>());
            var messages  = Group(message01, message02, message03, message04, message05, message06);

            //messages til billeder
            Student       student1   = Student.GetByID(2);
            List <Person> recipients = new List <Person>();

            recipients.Add(student1);
            Creator.CreateMessage(student1, "Angående matematik eksamen", "Hej alle kursister på tredje år.  <br/> Lokale til matematik eksamen er skiftet til 301a, tidspunkt er ikke ændret.  <br/> Mvh,  <br/> Studieordning på VUC", recipients, new List <string>());
            // Courses
            WriteSetupMessageIndent("Creating courses");
            var course01 = Course.New("Dansk A", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course02 = Course.New("Matematik A", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course03 = Course.New("Fysik A", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course04 = Course.New("Kemi B", "I kemi B får du kendskab til kemiens centrale begreber og eksperimentelle arbejdsmetoder sammen med en forståelse for stoffers opbygning og kemiske reaktioner.");
            var course05 = Course.New("Engelsk A", "I engelsk A får du et solidt kendskab til det engelske sprogs mundtlige og skriftlige udtryksformer og lærer at begå dig sprogligt i en globaliseret verden.");
            var course06 = Course.New("Samfund B", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course07 = Course.New("Historie B", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course08 = Course.New("Idræt C", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course09 = Course.New("Geografi B", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var course10 = Course.New("Religion B", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque non ipsum nec libero tincidunt convallis quis nec turpis. Cras lobortis condimentum vestibulum. Integer felis lectus, imperdiet eu commodo vel, tristique accumsan elit. Aenean mattis metus nibh, quis vestibulum elit vulputate sed. Duis cursus suscipit velit, at egestas massa lacinia et. Phasellus elementum arcu lectus, et convallis massa dictum nec. Aliquam erat volutpat. Mauris congue nibh sapien, id facilisis nibh cras amet.");
            var courses  = Group(course01, course02, course03, course04, course05, course06, course07, course08, course09, course10);

            // Course Students
            WriteSetupMessageIndent("Adding students to courses");
            foreach (Course course in courses)
            {
                foreach (Student student in students)
                {
                    course.AddStudent(student);
                }
            }
            // Course Teachers
            WriteSetupMessageIndent("Adding teachers to courses");
            course01.AddTeacher(teacher01);
            course01.AddTeacher(teacher02);
            course02.AddTeacher(teacher02);
            course03.AddTeacher(teacher03);
            course04.AddTeacher(teacher04);
            course05.AddTeacher(teacher05);
            course06.AddTeacher(teacher06);
            course07.AddTeacher(teacher07);
            course08.AddTeacher(teacher08);
            course09.AddTeacher(teacher09);
            course09.AddTeacher(teacher10);
            course10.AddTeacher(teacher10);
            // Lessons
            GenerateLessons("05", "09", "2016", 40, courses, rooms);
            // CustomLesson
            Lesson customLesson = Lesson.GetByConditions("DateTime='2017-01-24 10:00:00'").Single();

            customLesson.Description = "Lav opgaverne i den vedhæftede fil";
            Commands.InsertInto("lessonfile", customLesson.ID.ToString(), "opgaver.pdf");


            //// AssignmentDescriptions --- KOMMENTERET UD TIL AT LAVE BILLEDER AF DESIGN
            //WriteSetupMessageIndent("Creating AssignmentDescriptions");
            //const string description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent et nisl ipsum. Nunc nec eros vel dolor semper maximus. Suspendisse cursus in mi quis vehicula. Quisque elit risus, aliquet sit amet sem ut, facilisis eleifend libero. Donec ultricies nibh ut quam condimentum, non sollicitudin leo sed.";
            //var deadline = DateTime.Today;
            //var assignmentDescriptions = new List<AssignmentDescription>();
            //foreach (Course course in courses)
            //{
            //    assignmentDescriptions.Add(AssignmentDescription.New(course, "Title", description, deadline.AddDays(Rng.Next(-50, 50)), Group<string>()));
            //    assignmentDescriptions.Add(AssignmentDescription.New(course, "Title", description, deadline.AddDays(Rng.Next(-50, 50)), Group<string>()));
            //    assignmentDescriptions.Add(AssignmentDescription.New(course, "Title", description, deadline.AddDays(Rng.Next(-50, 50)), Group<string>()));
            //    assignmentDescriptions.Add(AssignmentDescription.New(course, "Title", description, deadline.AddDays(Rng.Next(-50, 50)), Group<string>()));
            //    assignmentDescriptions.Add(AssignmentDescription.New(course, "Title", description, deadline.AddDays(Rng.Next(-50, 50)), Group<string>()));
            //}
            //// Assignments
            //WriteSetupMessageIndent("Creating Assignments");
            //var assignments = new List<Assignment>();
            //foreach (AssignmentDescription assignmentDescription in assignmentDescriptions)
            //{
            //    List<Student> choices = new List<Student>(students);
            //    choices.RemoveAt(Rng.Next(0, choices.Count - 1));
            //    assignments.AddRange(choices.Select(student =>
            //        Assignment.New(assignmentDescription, student, "Lorem ipsum dolor sit amet, consectetur cras amet.", Group<string>())));
            //}
            //// AssignmentGrades
            //WriteSetupMessageIndent("Creating AssignmentGrades");
            //foreach (Assignment assignment in assignments)
            //    assignment.Grade = AssignmentGrade.New(TakeRandom(Common.ValidGrades.ToList()), "Vi gennemgår resultaterne af disse afleveringer i klassen", assignment);


            Creator.CreateAssignmentDescription(course01, "Dansk A, analyse af selvvalgt novelle", "Lav en analyse af en novelle, som følger analyse-kravene i kapitel 7", (DateTime.Now - TimeSpan.FromDays(5)), Group <string>());
            Creator.CreateAssignmentDescription(course02, "Matematik A, test af eksamenssæt", "Fuldfør til egen evne eksamenssættet fra sidste år", (DateTime.Now - TimeSpan.FromDays(1)), Group <string>());
            AssignmentDescription assignmentDescription1 = AssignmentDescription.GetLatest();
            List <string>         aflevering             = new List <string>();

            aflevering.Add("eksamenssæt.txt");
            Creator.CreateAssignment(assignmentDescription1, student1, "Vi gennemgår resultaterne af disse afleveringer i klassen", aflevering);
            Assignment.GetLatest().Grade = AssignmentGrade.New("10", "Vi gennemgår resultaterne af disse afleveringer i klassen", Assignment.GetLatest());
            Creator.CreateAssignmentDescription(course03, "Fysik A, tyngdekraft", "Lav en analyse af de forsøg vi foretog af tyngdekraften", DateTime.Now.AddDays(5), Group <string>());

            // CourseGrades
            WriteSetupMessageIndent("Creating CourseGrades");
            foreach (Course course in courses)
            {
                foreach (Student student in students)
                {
                    CourseGrade.New(course, student, TakeRandom(Common.ValidGrades.ToList()), "");
                }
            }
            List <CourseGrade> cg = CourseGrade.GetByConditions("StudentID=" + student01.ID);

            cg[0].Grade   = "10";
            cg[0].Comment = "Godt gået, deltag lidt mere i timerne for at få 12.";
            cg[1].Grade   = "02";
            cg[1].Comment = "Det er for dårligt, deltag mere i timerne og lav dine afleveringer.";
            cg[2].Grade   = "7";
            cg[2].Comment = "Du klarer dig fint, jeg ved du kan gøre det bedre.";
            cg[3].Grade   = "4";
            cg[3].Comment = "Deltag i undervisning og aflever dine afleveringer.";
            cg[4].Grade   = "02";
            cg[4].Comment = "Ved du kan gøre det bedre.";
            cg[5].Grade   = "-3";
            cg[5].Comment = "Tag dig sammen, og deltag i undervisningen.";
            cg[6].Grade   = "7";
            cg[6].Comment = "Du klarer dig godt, brug lidt mere tid på dine afleveringer.";
            cg[7].Grade   = "12";
            cg[7].Comment = "Du deltager aktivt i undervisning. Godt at se!";
            cg[8].Grade   = "12";
            cg[8].Comment = "Godt klaret, godt at se.";
            cg[9].Grade   = "00";
            cg[9].Comment = "Du skal begynde at deltage i undervisningen.";
        }
Esempio n. 52
0
 public bool RemoveLesson(Lesson lesson) => _lessonDAO.Remove(lesson);
Esempio n. 53
0
        private void RepeatLesson(Lesson l, RepeatMode rm, bool eoy, int nrepeats)
        {
            List<DateTime> dates = new List<DateTime>();

            DateTime dt = DateTime.Now;
            bool hitEnd = false;
            while(!hitEnd)
            {
                // Get next date
                switch (rm)
                {
                    case RepeatMode.None:
                        hitEnd = true;
                        break;
                    case RepeatMode.Weekly:
                        dt = dt.AddDays(7);
                        break;
                    case RepeatMode.Biweekly:
                        dt = dt.AddDays(14);
                        break;
                    case RepeatMode.Monthly:
                        dt = ProjectToNextMonth(dt);
                        break;
                    default:
                        throw new Exception("Bad params");
                }
                if (eoy && dt.Year != DateTime.Now.Year)
                    hitEnd = true;
                else if (!eoy && nrepeats-- <= 0)
                    hitEnd = true;

                if (!hitEnd)
                    dates.Add(dt);
            }

            CloneLessons(l, dates);
        }
Esempio n. 54
0
 public bool InsertLessonVideo(Lesson lesson, string title, string path) => _lessonDAO.InsertVideo(lesson, title, path);
Esempio n. 55
0
        private void DeleteFutures(Lesson l)
        {
            StartBulkEditOperation(Modes.Lessons);

            for (int i = lessonList.Count - 1; i >= 0; i--)
            {
                Lesson lsn = (Lesson)lessonList[i];
                if ((lsn.RepeaterKey == l.RepeaterSequenceKey ||
                     lsn.Key == l.RepeaterSequenceKey) &&
                    lsn.DateTimeStart >= l.DateTimeStart)
                {
                    Datalist_SetPosition(i);
                    buttonDelete_Click(null, null);
                }
            }
            CompleteBulkEditOperation();
        }
Esempio n. 56
0
 public bool RemoveLessonVideo(Lesson lesson, LessonVideo lessonVideo) => _lessonDAO.RemoveVideo(lesson, lessonVideo);
        public async Task <IActionResult> RegistTrial([FromBody] TrialLessonAndLearnerModel trialLessonViewModel)
        {
            var result         = new Result <Lesson>();
            var lesson         = new Lesson();
            var payment        = new Payment();
            var learner        = new Learner();
            var invoiceWaiting = new InvoiceWaitingConfirm();
            var invoice        = new Invoice();

            using (var dbContextTransaction = _ablemusicContext.Database.BeginTransaction())
            {
                learner.FirstName  = trialLessonViewModel.FirstName;
                learner.LastName   = trialLessonViewModel.LastName;
                learner.ContactNum = trialLessonViewModel.ContactNum;
                learner.Email      = trialLessonViewModel.Email;
                learner.EnrollDate = toNZTimezone(DateTime.UtcNow);
                learner.OrgId      = trialLessonViewModel.OrgId;
                learner.CreatedAt  = toNZTimezone(DateTime.UtcNow);
                learner.IsActive   = 1;
                //learner.LearnerLevel = 0;
                learner.PaymentPeriod = 1;
                // learner.LevelType = 1;
                _ablemusicContext.Add(learner);
                await _ablemusicContext.SaveChangesAsync();

                // var fundItem = new Fund { Balance = 0, LearnerId = newLearner.LearnerId };
                _ablemusicContext.Add(new Fund {
                    Balance = 0, LearnerId = learner.LearnerId
                });
                await _ablemusicContext.SaveChangesAsync();

                _ablemusicContext.Add(new User
                {
                    UserName   = "******" + learner.LearnerId.ToString(),
                    Password   = "******",
                    CreatedAt  = toNZTimezone(DateTime.UtcNow),
                    RoleId     = 4,
                    IsActivate = 1
                });
                await _ablemusicContext.SaveChangesAsync();

                lesson.LearnerId             = learner.LearnerId;
                lesson.RoomId                = trialLessonViewModel.RoomId;
                lesson.TeacherId             = trialLessonViewModel.TeacherId;
                lesson.OrgId                 = trialLessonViewModel.OrgId;
                lesson.IsCanceled            = 0;
                lesson.Reason                = null;
                lesson.CreatedAt             = toNZTimezone(DateTime.UtcNow);
                lesson.CourseInstanceId      = null;
                lesson.GroupCourseInstanceId = null;
                lesson.IsTrial               = 1;
                lesson.BeginTime             = trialLessonViewModel.BeginTime;
                lesson.EndTime               = trialLessonViewModel.EndTime;
                lesson.IsChanged             = 2;
                lesson.IsConfirm             = 0;
                lesson.TrialCourseId         = trialLessonViewModel.TrialCourseId;
                lesson.IsPaid                = trialLessonViewModel.IsPayNow ? (short)1 : (short)0;

                payment.PaymentMethod = trialLessonViewModel.PaymentMethod;
                payment.LearnerId     = learner.LearnerId;
                payment.Amount        = trialLessonViewModel.Amount;
                payment.CreatedAt     = toNZTimezone(DateTime.UtcNow);
                payment.StaffId       = trialLessonViewModel.StaffId;
                payment.InvoiceId     = null;
                payment.BeforeBalance = null;
                payment.AfterBalance  = null;
                payment.PaymentType   = 3;
                payment.IsConfirmed   = 0;
                payment.Comment       = null;

                invoiceWaiting.LessonFee   = trialLessonViewModel.Amount;
                invoiceWaiting.LearnerId   = learner.LearnerId;
                invoiceWaiting.LearnerName = await _ablemusicContext.Learner.
                                             Where(l => l.LearnerId == learner.LearnerId).Select(l => l.FirstName).FirstOrDefaultAsync();

                invoiceWaiting.BeginDate = trialLessonViewModel.BeginTime.Value.Date;
                invoiceWaiting.EndDate   = trialLessonViewModel.BeginTime.Value.Date;
                invoiceWaiting.TotalFee  = trialLessonViewModel.Amount;
                invoiceWaiting.DueDate   = trialLessonViewModel.BeginTime.Value.Date.AddDays(7);
                invoiceWaiting.PaidFee   = 0;
                invoiceWaiting.OwingFee  = trialLessonViewModel.Amount;
                invoiceWaiting.CreatedAt = toNZTimezone(DateTime.UtcNow);
                invoiceWaiting.IsPaid    = 0;
                invoiceWaiting.TermId    = await _ablemusicContext.Term.
                                           Where(t => t.BeginDate <= trialLessonViewModel.BeginTime.Value &&
                                                 t.EndDate >= trialLessonViewModel.BeginTime.Value
                                                 ).Select(l => l.TermId).FirstOrDefaultAsync();

                invoiceWaiting.LessonQuantity = 1;
                invoiceWaiting.CourseName     = "Trial Lesson";
                invoiceWaiting.IsConfirmed    = 1;
                invoiceWaiting.IsEmailSent    = 0;
                invoiceWaiting.IsActivate     = 1;

                List <Lesson>           conflictRooms          = new List <Lesson>();
                List <Lesson>           conflictTeacherLessons = new List <Lesson>();
                DateTime                beginTime = lesson.BeginTime.Value.AddMinutes(-60);
                DateTime                endTime   = lesson.EndTime.Value.AddMinutes(60);
                var                     lessonConflictCheckerService = new LessonConflictCheckerService(_ablemusicContext, lesson);
                Result <List <object> > lessonConflictCheckResult;
                try
                {
                    lessonConflictCheckResult = await lessonConflictCheckerService.CheckBothRoomAndTeacher();
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    result.IsSuccess    = false;
                    result.ErrorMessage = ex.Message;
                    return(BadRequest(result));
                }
                if (!lessonConflictCheckResult.IsSuccess)
                {
                    return(BadRequest(lessonConflictCheckResult));
                }

                try
                {
                    if (trialLessonViewModel.IsPayNow)
                    {
                        await _ablemusicContext.Payment.AddAsync(payment);
                    }
                    else
                    {
                        await _ablemusicContext.InvoiceWaitingConfirm.AddAsync(invoiceWaiting);

                        await _ablemusicContext.SaveChangesAsync();

                        invoiceWaiting.InvoiceNum = invoiceWaiting.WaitingId.ToString();
                        _mapper.Map(invoiceWaiting, invoice);
                        invoice.IsActive = 1;
                        await _ablemusicContext.Invoice.AddAsync(invoice);
                    }
                    lesson.InvoiceNum = invoiceWaiting.InvoiceNum;
                    await _ablemusicContext.Lesson.AddAsync(lesson);

                    await _ablemusicContext.SaveChangesAsync();

                    dbContextTransaction.Commit();
                }
                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    result.IsSuccess    = false;
                    result.ErrorMessage = ex.Message;
                    return(BadRequest(result));
                }
                result.Data = lesson;
                return(Ok(result));
            }
        }
Esempio n. 58
0
 public EditLessonView(Lesson _inputLesson)
 {
     InitializeComponent();
     LessonToEdit = _inputLesson;
     Students     = new ObservableCollection <Student>(VirtualCollegeContext.GetAllStudents());
 }
Esempio n. 59
0
    public List<Unit> GetUnits(String Language)
    {
        List<Unit> Units = new List<Unit>();
           SqlConnection con = new SqlConnection(
           WebConfigurationManager.ConnectionStrings["iLearnConnectionString"].ConnectionString);

           string sql = "";
           sql = "EXEC [dbo].[GetUnits] ";
           sql += "@Language = N'{0}'";
           sql = String.Format(sql, Language);

           SqlCommand cmd = new SqlCommand(sql, con);
           SqlCommand cmd2;
           SqlDataReader reader2;
           try
           {
          con.Open();
          SqlDataReader reader = cmd.ExecuteReader();
          if (reader.HasRows)
          {
             int Unit;
             String Title;
             while (reader.Read())
             {
                Unit = Convert.ToInt32(reader["unitNumber"]);
                Title = reader["UnitTitle"].ToString();
                Unit newUnit = new Unit(Unit, Title);
                Units.Add(newUnit);
             }
             reader.Close();
          }

          foreach (Unit u in Units)
          {
             int Unit = u.UnitID;

             sql = "EXEC [dbo].[GetLessons] ";
             sql += "@Language = N'{0}',";
             sql += "@Unit = {1}";
             sql = String.Format(sql, Language, Unit);
             cmd2 = new SqlCommand(sql, con);
             reader2 = cmd2.ExecuteReader();
             if (reader2.HasRows)
             {
                while (reader2.Read())
                {
                    int lessonID = Convert.ToInt32(reader2["lessonNumber"]);
                    String LessonTitle = reader2["LessonTitle"].ToString();
                    String LessonType = reader2["LessonType"].ToString();
                    Lesson newLesson = new Lesson(lessonID, Unit, LessonTitle, LessonType);
                    u.addLesson(newLesson);
                }
             }
          }
           }
           catch (Exception err)
           {
          con.Close();
           }
           finally
           {
          con.Close();
           }

           return Units;
    }
Esempio n. 60
0
 public bool InsertLesson(Lesson lesson) => _lessonDAO.Insert(lesson);