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)); } }
static void AudienceChoice() { IAudienceReposytory audienceReposytory = Factories.GetFactory().GetAudienceReposytory(); string key; do { Console.WriteLine("What do u want to do? Get all audiences?(all). Add audience?(add). Update?(update). Delete?(del). To back enter (b)"); key = Console.ReadLine(); try { if (key == "all") { 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(); } else if (key == "add") { Console.WriteLine("Enter id for new audience: "); int ID_for_new_elem = int.Parse(Console.ReadLine()); Console.WriteLine("Enter number for new audience: "); int Number_for_new_subject = int.Parse(Console.ReadLine()); audienceReposytory.Add(new Audience { Id = ID_for_new_elem, Number = Number_for_new_subject }); } else if (key == "update") { Console.WriteLine("Enter id for new audience: "); int ID_for_new_elem = int.Parse(Console.ReadLine()); Console.WriteLine("Enter number for new audience: "); int Number_for_new_subject = int.Parse(Console.ReadLine()); audienceReposytory.Update(new Audience { Id = ID_for_new_elem, Number = Number_for_new_subject }); } else if (key == "del") { Console.WriteLine("Enter id of audience u want to delete: "); int x = int.Parse(Console.ReadLine()); audienceReposytory.DeleteReference(new Models.Audience { Id = x }); audienceReposytory.Delete(new Models.Audience { Id = x }); } } catch (Exception e) { Console.WriteLine(e.Message); continue; } }while (key != "b"); }