Exemplo n.º 1
0
        public void CreateNewHelpRequestAssignment(DabDBContext db)
        {
            var student = db.Set <StudentEntity>().ToList();
            int i       = 0;

            foreach (var x in student)
            {
                Console.WriteLine(
                    " Nr:" + i + "\n" +
                    " Student ID " + x.AuId + "\n" +
                    " Student Name: " + x.Name);
                i++;
            }
            Console.WriteLine("Type Nr of the user to request help:");
            int id = Convert.ToInt32(Console.ReadLine());

            var shadow     = db.Set <AssignmentStudentEntity>().ToList();
            var assignment = db.Set <AssignmentEntity>().ToList();

            i = 0;
            foreach (var x in assignment)
            {
                Console.WriteLine(
                    " Nr:" + i + "\n" +
                    " Exercise Id: " + x.AssignmentId);
                i++;
            }
            Console.WriteLine("Type Nr of the exercise you want help with:");
            int assId = Convert.ToInt32(Console.ReadLine());

            shadow[assId].NeedHelp = true;
        }
Exemplo n.º 2
0
        public void CreateNewHelpRequestExercise(DabDBContext db)
        {
            var student = db.Set <StudentEntity>().ToList();
            int i       = 0;

            foreach (var x in student)
            {
                Console.WriteLine(
                    " Nr: " + i +
                    " Student ID " + x.AuId +
                    " Student Name: " + x.Name);
                i++;
            }
            Console.WriteLine("Type Nr of the user to request help:");
            int id = Convert.ToInt32(Console.ReadLine());

            var exercise = db.Set <ExerciseEntity>().ToList();

            i = 0;
            foreach (var x in exercise)
            {
                Console.WriteLine(
                    " Nr:" + i +
                    " Exercise Name: " + x.Lecture);
                i++;
            }
            Console.WriteLine("Type Nr of the exercise you want help with:");
            int exeid = Convert.ToInt32(Console.ReadLine());

            exercise[exeid].Student.Name = student[id].Name;
            Console.WriteLine("Write where you want help:");
            exercise[exeid].HelpWhere = Console.ReadLine();
        }
Exemplo n.º 3
0
        public void CreateNewCourse(DabDBContext db)
        {
            CourseEntity course = new CourseEntity();

            Console.WriteLine("Write name of course:");
            course.Name = Console.ReadLine();
            db.Add(course);
        }
Exemplo n.º 4
0
        public void CreateNewAssignment(DabDBContext db)
        {
            AssignmentEntity assignment = new AssignmentEntity();

            Console.WriteLine("Write Nr of the Asssignment:");
            assignment.AssignmentId = Convert.ToInt32(Console.ReadLine());
            db.Add(assignment);
        }
Exemplo n.º 5
0
        public void CreateNewTeacher(DabDBContext db)
        {
            TeacherEntity teacher = new TeacherEntity();

            Console.WriteLine("Write teacher name:");
            teacher.Name = Console.ReadLine();
            db.Add(teacher);
        }
Exemplo n.º 6
0
        public void CreateNewStudent(DabDBContext db)
        {
            StudentEntity student = new StudentEntity();

            Console.WriteLine("Write student name:");
            student.Name = Console.ReadLine();
            db.Add(student);
        }
Exemplo n.º 7
0
        public void CreateNewExecersise(DabDBContext db)
        {
            ExerciseEntity exercise = new ExerciseEntity();

            Console.WriteLine("Write Nr of the exercise:");
            exercise.Number = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Write name of lecture");
            exercise.Lecture = Console.ReadLine();
            db.Add(exercise);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            var  c    = new CreateData();
            var  db   = new DabDBContext();
            var  a    = new DummyData();
            var  v    = new Views(db);
            bool loop = true;

            Console.WriteLine("----------------------------------------------------------------------------------------");
            Console.WriteLine("Welcome to DabAflevering, for investigating the database use the following commands:");
            Console.WriteLine("----------------------------------------------------------------------------------------");

            while (loop == true)
            {
                Console.WriteLine("Press 1 to view data");
                Console.WriteLine("Press 2 To add Dummy Data");
                Console.WriteLine("Press 3 to create new data");
                Console.WriteLine("Press 4 to exit program");
                Console.WriteLine("----------------------------------------------------------------------------------------");

                var input = Console.ReadLine();

                switch (input)
                {
                case "1":
                    v.ViewsSwitcher();
                    Console.Clear();
                    break;

                case "2":
                    Console.Clear();
                    a.InsertDummyData();
                    break;

                case "3":
                    c.CreateDataHandler(db);
                    db.SaveChanges();
                    Console.Clear();
                    break;

                case "4":
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    Console.WriteLine("Bye bye!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    loop = false;
                    break;
                }
            }
        }
Exemplo n.º 9
0
        public void InsertDummyData()
        {
            using var db = new DabDBContext();

            TeacherEntity teacher1 = new TeacherEntity();

            teacher1.Name = "Henrik Kirk";
            db.Add(teacher1);

            TeacherEntity teacher2 = new TeacherEntity();

            teacher2.Name = "S�ren";
            db.Add(teacher2);

            TeacherEntity teacher3 = new TeacherEntity();

            teacher3.Name = "Michael";
            db.Add(teacher3);

            TeacherEntity teacher4 = new TeacherEntity();

            teacher4.Name = "Lars";
            db.Add(teacher4);

            StudentEntity student1 = new StudentEntity();

            student1.Name = "Sebastian";
            db.Add(student1);

            StudentEntity student2 = new StudentEntity();

            student2.Name = "Tobias";
            db.Add(student2);

            StudentEntity student0 = new StudentEntity();

            student0.Name = "Gustav";
            db.Add(student0);

            AssignmentEntity assignment1 = new AssignmentEntity();

            assignment1.Teacher = teacher2;
            db.Add(assignment1);
            AssignmentEntity assignment2 = new AssignmentEntity();

            assignment2.Teacher = teacher2;
            db.Add(assignment2);
            AssignmentEntity assignment3 = new AssignmentEntity();

            assignment3.Teacher = teacher3;
            db.Add(assignment3);


            CourseEntity course = new CourseEntity()
            {
                Name        = "Databaser",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher1
                    },
                    assignment1,
                    assignment2
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher1,
                    teacher2
                }
            };
            CourseEntity course3 = new CourseEntity()
            {
                Name        = "MMLS",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher3
                    }
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher4
                }
            };

            db.Add(course3);
            CourseEntity course2 = new CourseEntity()
            {
                Name        = "SWD",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher1
                    },
                    assignment3
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher3
                }
            };

            db.Add(course2);

            ExerciseEntity exercise1 = new ExerciseEntity();

            exercise1.Number    = 2;
            exercise1.Lecture   = "3 EF core";
            exercise1.Teacher   = teacher1;
            exercise1.Student   = student1;
            exercise1.HelpWhere = "Ex 3.1";
            exercise1.Course    = course;
            db.Add(exercise1);

            ExerciseEntity exercise2 = new ExerciseEntity();

            exercise2.Number    = 5;
            exercise2.Lecture   = "5 EF core";
            exercise2.Teacher   = teacher1;
            exercise2.Student   = student1;
            exercise2.HelpWhere = "Side 2";
            exercise2.Course    = course;
            db.Add(exercise2);


            ExerciseEntity exercise3 = new ExerciseEntity();

            exercise3.Number    = 1;
            exercise3.Lecture   = "Design patterns";
            exercise3.Teacher   = teacher3;
            exercise3.Student   = student0;
            exercise3.HelpWhere = "Det hele";
            exercise3.Course    = course2;
            db.Add(exercise3);

            ExerciseEntity exercise4 = new ExerciseEntity();

            exercise4.Number  = 4;
            exercise4.Lecture = "Functional Programming";
            exercise4.Teacher = teacher1;
            exercise4.Student = student0;
            exercise4.Course  = course2;
            db.Add(exercise4);

            ExerciseEntity exercise5 = new ExerciseEntity();

            exercise5.Number  = 5;
            exercise5.Lecture = "Some math";
            exercise5.Teacher = teacher4;
            exercise5.Student = student2;
            exercise5.Course  = course3;
            db.Add(exercise5);

            StudentCourseEntity joinedStudCourse = new StudentCourseEntity()
            {
                Students = student0,
                Courses  = course,
            };

            db.Add(joinedStudCourse);
            joinedStudCourse = new StudentCourseEntity()
            {
                Students = student1,
                Courses  = course,
            };
            db.Add(joinedStudCourse);
            joinedStudCourse = new StudentCourseEntity()
            {
                Students = student2,
                Courses  = course,
            };
            var testAss = new AssignmentStudentEntity()
            {
                Students    = student0,
                Assignments = assignment1,
            };

            db.Add(joinedStudCourse);

            db.SaveChanges();
        }
Exemplo n.º 10
0
 public Views(DabDBContext db)
 {
     _db = db;
     StudentEntity student = new StudentEntity();
 }
Exemplo n.º 11
0
        public void CreateDataHandler(DabDBContext db)
        {
            bool leave = false;

            while (!leave)
            {
                Console.WriteLine("Press a key to create different objects");
                Console.WriteLine("1 for student, 2 for teacher");
                Console.WriteLine("3 for Exercise, 4 for Assignment, 5 for Course");
                Console.WriteLine("6 for help with exercise, 7 for help with assignment");
                Console.WriteLine("Any other key to go back");
                Console.WriteLine("----------------------------------------------------------------------------------------");
                var input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    CreateNewStudent(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "2":
                    CreateNewTeacher(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "3":
                    CreateNewExecersise(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "4":
                    CreateNewAssignment(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "5":
                    CreateNewCourse(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "6":
                    CreateNewHelpRequestExercise(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                case "7":
                    CreateNewHelpRequestAssignment(db);
                    Console.Clear();
                    Console.WriteLine("Created!");
                    Console.WriteLine("----------------------------------------------------------------------------------------");
                    break;

                default:
                    leave = true;
                    break;
                }
            }
        }