} //How List will be sorted (user select at the View) public List <Doctor> Doctors() //sorted doctors { List <Doctor> DocSortedList = new List <Doctor>(); if (HowToSort == "Alphabetically") //sorted doctors by alphabetically { var sortAlph = DocList.OrderBy(i => i.User.Lastname).ThenBy(i => i.User.Name).ThenBy(i => i.User.Patronymic); DocSortedList = sortAlph.ToList(); } else if (HowToSort == "Number_of_patients") //sorted doctors by number of patients { var sortByNumber = DocList.OrderBy(i => i.NumberOfPatients); DocSortedList = sortByNumber.Reverse().ToList(); } else if (HowToSort == "Catagory") //sorted doctors by catagory { var sortByNumber = DocList.OrderBy(i => i.Category == "Higher").ThenBy(x => x.Category == "Second").ThenBy(y => y.Category == "First"); DocSortedList = sortByNumber.Reverse().ToList(); } else { DocSortedList = CreateListOf.MedicalStuff(); } return(DocSortedList); }
public List <Patient> Patients() //sorted patients { List <Patient> PatientSortedList = new List <Patient>(); if (HowToSort == "Alphabetically") //sorted doctors by alphabetically { var sortAlph = PatientList.OrderBy(i => i.User.Lastname).ThenBy(i => i.User.Name).ThenBy(i => i.User.Patronymic); PatientSortedList = sortAlph.ToList(); } else if (HowToSort == "Birthday") { var sortByBirth = PatientList.OrderBy(i => i.User.Birthday); PatientSortedList = sortByBirth.ToList(); } else { PatientSortedList = CreateListOf.Patients(); } return(PatientSortedList); }