Beispiel #1
0
        static void GetAllData()
        {
            IAudienceReposytory audienceReposytory = Factories.GetFactory().GetAudienceReposytory();
            IGroupReposytory    groupReposytory    = Factories.GetFactory().GetGroupReposytory();
            ILessonReposytory   lessonReposytory   = Factories.GetFactory().GetLessonReposytory();
            ILecturerReposytory lecturerReposytory = Factories.GetFactory().GetLecturerReposytory();
            IHistoryReposytory  historyReposytory  = Factories.GetFactory().GetHistoryReposytory();
            IStudentReposytory  studentReposytory  = Factories.GetFactory().GetStudentReposytory();
            ISubjectReposytory  subjectReposytory  = Factories.GetFactory().GetSubjectReposytory();

            Console.WriteLine("************Shedule************");
            Console.WriteLine();
            foreach (var lessons in lessonReposytory.GetAllLessons())
            {
                Console.WriteLine(string.Format("ID: {0}, Subject: {1}, Lecturer: {2}, Audience: {3}, " +
                                                "Academic group: {4},Time:{5}, Day: {6}, Type: {7}",
                                                lessons.Id, lessons.Subject, lessons.Lecturer, lessons.Audience, lessons.Academic_group, lessons.Time, lessons.Day, lessons.Type));
            }
            Console.WriteLine();
            Console.WriteLine("There are such audiences: ");
            Console.WriteLine();
            foreach (var audiences in audienceReposytory.GetAllAudiences())
            {
                Console.WriteLine(string.Format("ID: {0}, Number: {1}",
                                                audiences.Id, audiences.Number));
            }
            Console.WriteLine();
            Console.WriteLine("There are such groups: ");
            Console.WriteLine();
            foreach (var groups in groupReposytory.GetAllGroups())
            {
                Console.WriteLine(string.Format("ID: {0}, Name: {1}",
                                                groups.Id, groups.Name));
            }
            Console.WriteLine();
            Console.WriteLine("There are such lecturers: ");
            Console.WriteLine();
            foreach (var lecturers in lecturerReposytory.GetAllLecturers())
            {
                Console.WriteLine(string.Format("ID: {0}, First name: {1}, Last name: {2}, Reputation: {3}, Phone: {4}",
                                                lecturers.Id, lecturers.FirstName, lecturers.LastName, lecturers.Reputation, lecturers.Phone));
            }
            Console.WriteLine();
            Console.WriteLine("There are such students: ");
            Console.WriteLine();
            foreach (var students in studentReposytory.GetAllStudents())
            {
                Console.WriteLine(string.Format("ID: {0}, First name: {1}, Last name: {2}, Birth: {3}, Academic group: {4}",
                                                students.Id, students.FirstName, students.LastName, students.Birth, students.Group_number));
            }
            Console.WriteLine();
            Console.WriteLine("There are such subjects: ");
            Console.WriteLine();
            foreach (var subjects in subjectReposytory.GetAllSubjects())
            {
                Console.WriteLine(string.Format("ID: {0}, Name: {1}", subjects.Id, subjects.Name));
            }
            Console.WriteLine();
            Console.WriteLine("History of using database: ");
            foreach (var history in historyReposytory.GetAllHistory())
            {
                Console.WriteLine(string.Format("ID: {0}, Lesson ID: {1}, Operation: {2}, Time: {3}",
                                                history.Id, history.Lesson_ID, history.Operation, history.OnTime));
            }
        }
Beispiel #2
0
        static void SubjectChoice()
        {
            ISubjectReposytory subjectReposytory = Factories.GetFactory().GetSubjectReposytory();
            string             key;

            do
            {
                Console.WriteLine("What do u want to do? Get all subjects?(all). Add subject?(add). Update subject?(update). Delete?(del). To back enter (b)");
                key = Console.ReadLine();
                try
                {
                    if (key == "all")
                    {
                        Console.WriteLine("There are such subjects: ");
                        Console.WriteLine();
                        foreach (var subjects in subjectReposytory.GetAllSubjects())
                        {
                            Console.WriteLine(string.Format("ID: {0}, Name: {1}", subjects.Id, subjects.Name));
                        }
                        Console.WriteLine();
                    }
                    else if (key == "add")
                    {
                        Console.WriteLine("Enter id for new subject: ");
                        int ID_for_new_elem = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter name for new subject: ");
                        string Name_for_new_subject = Console.ReadLine();

                        subjectReposytory.Add(new Subject
                        {
                            Id   = ID_for_new_elem,
                            Name = Name_for_new_subject
                        });
                    }
                    else if (key == "update")
                    {
                        Console.WriteLine("Enter id of subject u want to update: ");
                        int ID_for_new_elem = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter name for new subject: ");
                        string Name_for_new_subject = Console.ReadLine();

                        subjectReposytory.Update(new Subject
                        {
                            Id   = ID_for_new_elem,
                            Name = Name_for_new_subject
                        });
                    }
                    else if (key == "del")
                    {
                        Console.WriteLine("Enter id of subject u want to delete: ");
                        int x = int.Parse(Console.ReadLine());
                        subjectReposytory.DeleteReference(new Models.Subject
                        {
                            Id = x
                        });
                        subjectReposytory.Delete(new Models.Subject
                        {
                            Id = x
                        });
                    }
                }
                catch (Exception e) { Console.WriteLine(e.Message);  continue; }
            } while (key != "b");
        }