/// <summary> /// Returns the Modul that matches with the given name and the highest current version of the editable Semester /// </summary> /// <param name="name">name of the modul</param> /// <returns>null if no modul with this name was found</returns> public Modul getModuleByNameAttendVersion(String name) { name = name.ToLower(); List <Modul> modules = new List <Modul>(); List <Modul> mod = getEditableModules(); Modul newest = new Modul() { Version = 0 }; for (int i = 0; i < mod.Count; i++) { bool reverse = false; for (int j = 0; j < mod[i].Descriptions.Count; j++) { ModulPartDescription mpd = mod[i].Descriptions.ToList()[j]; if (mpd.Name.Equals(GlobalNames.getModulNameText()) && mpd.Description.ToLower().Equals(name)) { if ((mod[i].Version > newest.Version) || newest.Version == 0) { newest = mod[i]; reverse = true; } } } if (reverse) { i = -1; } } return(newest); }
/*private List<String> GetAllIntResults(String s) * { * List<String> results = new List<String>(); * * foreach (Modul m in getAllModulesFromYear(Convert.ToInt32(s))) * { * results.Add(getNameFromModule(m)); * } * foreach (Modulhandbook m in getAllModulHandbooksFromYear(Convert.ToInt32(s))) * { * results.Add(m.Name); * } * * return results; * }*/ /// <summary> /// Returns the Name of a Modul /// </summary> /// <param name="m"></param> /// <returns></returns> public String getNameFromModule(Modul m) { foreach (ModulPartDescription d in m.Descriptions) { if (d.Name.Equals(GlobalNames.getModulNameText())) { return(d.Description); } } return("No name found for requested module."); }
private static String getModulname(List <ModulPartDescription> mpdList) { String modulname = null; foreach (ModulPartDescription d in mpdList) { if (d.Name.Equals(GlobalNames.getModulNameText())) { modulname = d.Description; } } return(modulname); }
//no longer valid /// <summary> /// returns the modul that matches with the given name from current semester /// </summary> /// <param name="name">name from the modul</param> /// <returns>null if no module with this name is found</returns> public Modul getModuleByName(String name) { name = name.ToLower(); DbSet <Modul> subj = context.Modules; foreach (Modul m in subj) { foreach (ModulPartDescription d in m.Descriptions) { if (d.Name.Equals(GlobalNames.getModulNameText()) && d.Description.ToLower().Equals(name)) { return(m); } } } return(null); }
/// <summary> /// returns a list of modules which names contain the given string /// </summary> /// <param name="substr">string to search for</param> /// <returns>empty list if nothing is found</returns> public List <Modul> getAllModulesThatContainStr(String substr) { substr = substr.ToLower(); List <Modul> results = new List <Modul>(); DbSet <Modul> subj = context.Modules; foreach (Modul m in subj) { foreach (ModulPartDescription d in m.Descriptions) { if (d.Name.Equals(GlobalNames.getModulNameText()) && d.Description.ToLower().Contains(substr)) { results.Add(m); } } } return(results); }