Ejemplo n.º 1
0
        public void AddLesson()
        {
            Lesson       lesson = new Lesson();
            TakenLessons taken  = new TakenLessons();

            Console.WriteLine("Enter lesson theme:");
            lesson.Name = Console.ReadLine();
            db.GetTable <Lesson>().InsertOnSubmit(lesson);
            db.SubmitChanges();
            // UpdateTakenLessons();
        }
Ejemplo n.º 2
0
        public void SetLessonToStudent()
        {
            GetStudents();

            GetLessons();
            Console.WriteLine("Enter ID of student");
            if (!int.TryParse(Console.ReadLine(), out int stID))
            {
                Console.WriteLine("Uncorrect value"); return;
            }
            if (db.GetTable <Student>().SingleOrDefault(x => x.ID == stID) == null)
            {
                Console.WriteLine("There is no such student"); return;
            }
            Console.WriteLine("Enter ID of lesson");
            if (!int.TryParse(Console.ReadLine(), out int lsID))
            {
                Console.WriteLine("Uncorrect value"); return;
            }
            if (db.GetTable <Lesson>().SingleOrDefault(x => x.ID == lsID) == null)
            {
                Console.WriteLine("There is no such lesson"); return;
            }
            TakenLessons taken = new TakenLessons();

            taken.LessonID  = lsID;
            taken.StudentID = stID;
            if (db.GetTable <TakenLessons>().Contains(taken))
            {
                Console.WriteLine("Such entry already exists");
            }
            else
            {
                db.GetTable <TakenLessons>().InsertOnSubmit(taken);
                db.SubmitChanges();
            }
        }