public IEnumerable <string> GetAllTeachers() { var teachers = GenerateTeachers(); var univerLogic = new UniverLogic(); var univers = univerLogic.GenerateUnivers(); var univerTeachers = from teacher in teachers join univer in univers on teacher.UniverId equals univer.Id select new UniverTeacher(teacher, univer); List <string> teachersList = new List <string>(); foreach (var ut in univerTeachers) { teachersList.Add ( $" {ut.Teacher.GendersDisplayNames[ut.Teacher.Gender]} " + $"{ut.Teacher.Name} " + $"{ut.Teacher.Patronymic} teaches " + $"{ut.Teacher.Lesson} at " + $"{ut.Univer.Name}. " ); } return(teachersList); }
public string GetName(Student student) { var univerLogic = new UniverLogic(); var univers = univerLogic.GenerateUnivers(); var univer = univers .SingleOrDefault(u => u.Id == student.UniverId); if (univer == null) { throw new Exception($" Univer with Id = {student.UniverId} " + $"in which student {student.Name} " + $"(with Id = {student.Id}) is studying " + "is not found in DataBase 'Univers'! "); } return($" A student {student.Name} aged {student.Age} years " + $"studying at {univer.Name}. "); }
internal List <string> GetAllStudents() { var studentLogic = new StudentLogic(); var students = studentLogic.GenerateStudents(); var univerLogic = new UniverLogic(); var univers = univerLogic.GenerateUnivers(); var univerStudent = from student in students join univer in univers on student.UniverId equals univer.Id select new UniverStudent(student, univer); List <string> studentsList = new List <string>(); foreach (var uStudent in univerStudent) { studentsList.Add ( $" A student {uStudent.Student.Name} aged {uStudent.Student.Age} " + $"years studying at {uStudent.Univer.Name}. " ); } return(studentsList); }
public List <string> GetUniverStudents(string univerName) { UniverLogic univerLogic = new UniverLogic(); List <Univer> univerList = univerLogic.GenerateUnivers(); var univerListSortedName = univerList .Where(univer => univer.Name == univerName) .ToList(); if (!univerListSortedName.Any()) { throw new Exception($" University with name {univerName} " + "was not found in the database 'Univer'. "); } var studentLogic = new StudentLogic(); var studentList = studentLogic.GenerateStudents(); var univerStudents = from student in studentList join univer in univerListSortedName on student.UniverId equals univer.Id select new UniverStudent(student, univer); return(univerStudents .Select(su => $" {su.Student.Name} studies at {su.Univer.Name} ") .ToList()); }
public string GetOneTeacher(int teacherId) { var teachers = GenerateTeachers(); var univerLogic = new UniverLogic(); var univers = univerLogic.GenerateUnivers(); var univerTeachers = from teacher in teachers join univer in univers on teacher.UniverId equals univer.Id select new UniverTeacher(teacher, univer); var ut = univerTeachers.SingleOrDefault(uT => uT.Teacher.Id == teacherId); if (ut == null) { throw new Exception($" Teacher with Id = {teacherId} not found. "); } return($" {ut.Teacher.GendersDisplayNames[ut.Teacher.Gender]} " + $"{ut.Teacher.Name} " + $"{ut.Teacher.Patronymic} teaches " + $"{ut.Teacher.Lesson} at " + $"{ut.Univer.Name}. "); }