public void AddSubjectRegister(SubjectList aSubjectList) { if (aSubjectList.getCount() == 0) { Console.WriteLine("\n ************************************************************************"); Console.WriteLine("\t Para utilizar esta opcion debe agregar asignaturas."); Console.WriteLine("\n ************************************************************************"); } else { var newSubjectRegister = new SubjectRegister(); Console.WriteLine("\n Agregar registro de asignatura \n"); Console.WriteLine("\t Asignaturas disponibles para creacion de registro de asignatura: \n"); aSubjectList.ListSubjects(); Console.Write("\n \n Escriba el ID de la asignatura con que desea crear nuevo registro de asignatura: "); int id = Convert.ToInt32("0" + Console.ReadLine()); if (aSubjectList.GetIdList().Contains(id)) { newSubjectRegister.SetSubject(aSubjectList.SearchAndReturn(id)); newSubjectRegister.SetAtributes(lastId + 1); lastId++; this.subjectRegisters.Add(newSubjectRegister); } else { Console.WriteLine("Id invalido."); } } }
public void SearchSubject() { Console.WriteLine("\n ¿Por qué opción desea buscar? \n"); Console.WriteLine("1- Por Nombre"); Console.WriteLine("2- Por Carrera"); Console.Write("Elija una opción: "); int sOpt = Convert.ToInt32("0" + Console.ReadLine()); Console.Write("Digite el valor de busqueda: "); string searchValue = Console.ReadLine(); SubjectList searchResults = new SubjectList(); foreach (var subject in subjects) { switch (sOpt) { case 1: if (subject.Name.Contains(searchValue)) { searchResults.subjects.Add(subject); } break; case 2: if (subject.Career.Contains(searchValue)) { searchResults.subjects.Add(subject); } break; } } if (searchResults.subjects.Count == 0) { Console.WriteLine("\n ******************************************"); Console.Write("\t No se encontraron registros"); Console.WriteLine("\n ******************************************"); } else { searchResults.ListSubjects(); } }
static void ListSubject() { Console.Clear(); Subjects.ListSubjects(); Console.WriteLine("\n\n ¿Qué desea hacer? \n"); Console.WriteLine("1- Mantenerse en Lista"); Console.WriteLine("2- Menú Asignaturas"); Console.Write("\n Elija una opción: "); int subjectListOption = Convert.ToInt32("0" + Console.ReadLine()); switch (subjectListOption) { case 2: SubjectMenu(); break; default: ListSubject(); break; } }