/// <summary> /// Returns the highest version of the Module /// </summary> /// <param name="modul">The name of the Module</param> /// <returns></returns> private Modul GetHighestModulVersion(Modul modul) { ModulhandbookContext mhc = new ModulhandbookContext(); String Name = getNameFromModule(modul); return(getModuleByNameAttendVersion(Name)); }
/// <summary> /// This Function creates new Moduls. It's also called in order to 'edit' Moduls or change the Modulstate. Due to the Versionisierung /// </summary> /// <param name="modulpartdescriptions"></param> /// <param name="state"></param> /// <param name="owner"></param> /// <param name="autor"></param> /// <param name="lastChange"></param> /// <param name="subjects"></param> /// <param name="version"></param> /// <returns></returns> public Modul CreateModul(List <ModulPartDescription> modulpartdescriptions, ModulState state, Guid owner, Guid autor, DateTime lastChange, List <Subject> subjects, int version) { ModulhandbookContext mhc = new ModulhandbookContext(); Modul theNewModul = new Modul() { State = state, Owner = owner, Autor = autor, LastChange = lastChange, Subjects = new List <Subject>(), Descriptions = modulpartdescriptions, Version = version, Year = 2012 }; foreach (Subject s in mhc.Subjects) { foreach (Subject s2 in subjects) { if (s.SubjectID == s2.SubjectID) { s.Modules.Add(theNewModul); theNewModul.Subjects.Add(s); } } } mhc.SaveChanges(); return(theNewModul); }
/// <summary> /// Returns the next Semester. /// For Example: returns Wintersemester 2013 if the current Semester is Sommersemester 2013 /// </summary> /// <returns></returns> public Semester getEditableSemester() { ModulhandbookContext mhc = new ModulhandbookContext(); Semester next = new Semester(); DateTime date = DateTime.Now; if (DateTime.Now.Month >= 4 && DateTime.Now.Month < 10) { String compare = "Wintersemester " + DateTime.Now.Year + "/" + (DateTime.Now.Year + 1); next = mhc.Semesters.Where(s => s.Name.Equals(compare)).ToList <Semester>().First(); } else { String compare = ""; if (DateTime.Now.Month >= 10) { compare = "Sommersemester " + (DateTime.Now.Year + 1); } else { compare = "Sommersemester " + DateTime.Now.Year; } next = mhc.Semesters.Where(s => s.Name.Equals(compare)).ToList <Semester>().First(); } return(next); }
protected void Subject_Click(Object sender, EventArgs e) { ModulhandbookContext mhc = new ModulhandbookContext(); LinkButton link = sender as LinkButton; int id = Int32.Parse(link.ID.Substring(7)); Subject subject = mhc.Subjects.Where(s => s.SubjectID == id).ToList <Subject>().First(); List <Subject> list = GetSubjects(); Boolean delete = false; for (int i = 0; i < list.Count; i++) { if (list[i].SubjectID == id) { list.RemoveAt(i); delete = true; } } if (!delete) { list.Add(subject); } Session["Subjects"] = list; SubjectsTable.Rows.Clear(); DrawSubjects(); }
/// <summary> /// returns a list with all modulhandbooks /// </summary> /// <returns>returns empty list if nothing is found</returns> public List <Modulhandbook> getAllModulhandbooks() { List <Modulhandbook> resultList = new List <Modulhandbook>(); ModulhandbookContext context = new ModulhandbookContext(); foreach (Modulhandbook m in context.Modulhandbooks) { resultList.Add(m); } return(resultList); }
/// <summary> /// returns the corresponding Modul /// </summary> /// <param name="ID">The ModulId, not negative</param> /// <returns>returns null if nothing is found</returns> public Modul getModulById(int ID) { Modul toReturn = null; ModulhandbookContext context = new ModulhandbookContext(); foreach (Modul m in context.Modules) { if (m.ModulID == ID) { toReturn = m; } } return(toReturn); }
private List <Subject> GetSubjects() { if (Session["Subjects"] == null) { List <Subject> toReturn = new List <Subject>(); int id = Int32.Parse(Request.QueryString["SubjectID"]); ModulhandbookContext mhc = new ModulhandbookContext(); return(mhc.Subjects.Where(s => s.SubjectID == id).ToList <Subject>()); } else { return((List <Subject>)Session["Subjects"]); } }
/// <summary> /// returns all the modulhandbooks that belong to the given studysubject /// </summary> /// <param name="name">name from the study subjecz</param> /// <returns>empty list if no modulhandbooks were found</returns> public List <Modulhandbook> getAllModulHandbooksByStudySubject(String name) { name = name.ToLower(); List <Modulhandbook> resultList = new List <Modulhandbook>(); ModulhandbookContext context = new ModulhandbookContext(); foreach (Modulhandbook m in context.Modulhandbooks) { if (m.Name.ToLower().Equals(name)) { resultList.Add(m); } } return(resultList); }
/// <summary> /// Delete the current Modul /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteModulBtn_Click(object sender, EventArgs e) { Modul modul = GetModulByQuerystring(); ArchiveLogic al = new ArchiveLogic(); ModulhandbookContext mhc = new ModulhandbookContext(); List <Modul> moduls = mhc.Modules.ToList <Modul>(); foreach (Modul m in moduls) { if (al.getNameFromModule(m) == al.getNameFromModule(modul)) { mhc.Modules.Remove(m); } } mhc.SaveChanges(); Response.Redirect("Default.aspx"); }
public List <Subject> getSubjectstoDisplay(String handbookName) { ModulhandbookContext mhc = new ModulhandbookContext(); String s = handbookName; List <Modulhandbook> list = new List <Modulhandbook>(); int id; bool isNum = Int32.TryParse(s, out id); if (isNum) { list = mhc.Modulhandbooks.Where(m => m.ModulhandbookID == id).ToList <Modulhandbook>(); } else { return(new List <Subject>()); } return(getAllSubjectsFromModulhandbook(list.First().ModulhandbookID)); }
/// <summary> /// Returns the Modules from the corresponding owner /// </summary> /// <returns></returns> public List <Modul> GetModulsModulverantwortlicher(HttpContext context, Guid owner) { ModulhandbookContext mhc = new ModulhandbookContext(); List <Modul> alleditableModules = getEditableModules(); List <Modul> highestVersion = new List <Modul>(); foreach (Modul m in alleditableModules) { highestVersion.Add(GetHighestModulVersion(m)); } highestVersion = RemoveDoubleModules(highestVersion); List <Modul> correctState = new List <Modul>(); for (int i = 0; i < highestVersion.Count; i++) { if (highestVersion[i].State != ModulState.archiviert) { correctState.Add(highestVersion[i]); } } if (context.User.IsInRole("Administrator")) { return(correctState); } else { List <Modul> correctOwner = new List <Modul>(); for (int i = 0; i < correctState.Count; i++) { if (correctState[i].Owner == owner) { correctOwner.Add(correctState[i]); } } return(correctOwner); } }
private void DrawHeader() { ArchiveLogic al = new ArchiveLogic(); ModulhandbookContext mhc = new ModulhandbookContext(); if (Request.QueryString["ModulhandbookID"] != null) { int MId = Int32.Parse(Request.QueryString["ModulhandbookID"]); List <Modulhandbook> books = mhc.Modulhandbooks.Where(m => m.ModulhandbookID == MId).ToList <Modulhandbook>(); Modulhandbook book = books.First(); ChosenModulhandbook.Text = "Modulhandbuch: " + book.Name + " FSPOYear: " + book.FspoYear + " Abschluss: " + book.Abschluss + " ValidSemester: " + book.ValidSemester; if (Request.QueryString["SubjectID"] != null) { int SId = Int32.Parse(Request.QueryString["SubjectID"]); List <Subject> subjects = mhc.Subjects.Where(s => s.SubjectID == SId).ToList <Subject>(); ChosenSubject.Text = "Subject: " + subjects.First().Name; } else { ChosenModulhandbook.Text = "Modulhandbuch: " + book.Name + " FSPOYear: " + book.FspoYear + " Abschluss: " + book.Abschluss + " ValidSemester: " + book.ValidSemester; } } }
//----------------------------Koordinator and Freigeber Logic end-----------------------------/// /// <summary> /// Returns a List of Moduls, which have the ModulState state /// </summary> /// <param name="state"></param> /// <returns></returns> public List <Modul> GetModulsByState(ModulState state) { ModulhandbookContext mhc = new ModulhandbookContext(); return(mhc.Modules.Where(m => m.State == state).ToList <Modul>()); }
/// <summary> /// Checks the User input /// </summary> /// <returns>Returns true, if everything is fine</returns> public bool CheckDescriptions() { List <ModulPartDescription> descriptions = GetModulpartDescriptions(); for (int i = 0; i < descriptions.Count; i++) { //Check for undone mandatory fields if (descriptions[i].IsNeeded) { if (descriptions[i].Description.Equals(defaultMPDs[i].Description)) { Session["Message"] = true; CheckforMessage("Ein Pflichtfeld muss noch bearbeitet werden"); jumpToDescription(i); return(false); } } //Check double Modules if (descriptions[i].Name.Equals(GlobalNames.getModulNameText())) { ModulhandbookContext mhc = new ModulhandbookContext(); ArchiveLogic al = new ArchiveLogic(); List <Modul> list = mhc.Modules.ToList <Modul>(); foreach (Modul m in list) { if (descriptions[i].Description == al.getNameFromModule(m)) { Session["Message"] = true; CheckforMessage("Ein Modul mit diesem Namen existiert schon!"); jumpToDescription(i); return(false); } } } //Check for invalide Types if (descriptions[i].Name.Equals(GlobalNames.getModulNameECTS()) || descriptions[i].Name.Equals(GlobalNames.getModulNameWeekHours()) || descriptions[i].Name.Equals(GlobalNames.getModulNameEffort())) { double Num; bool isNum = double.TryParse(descriptions[i].Description, out Num); if (!isNum) { Session["Message"] = true; CheckforMessage("Der Modulpunkt muss eine Zahl enthalten"); jumpToDescription(i); return(false); } } } //Check the Subjects List <Subject> subjects = GetSubjects(); //At least one Subject must be chosen if (subjects.Count < 1) { Session["Message"] = true; CheckforMessage("Sie wüssen mindestens ein Fach für das Modul festlegen!"); return(false); } //A Module cannot exist more then once inside a Modulhandbook if (subjects.Count >= 2) { for (int i = 0; i < subjects.Count; i++) { Modulhandbook m = subjects[i].Modulhandbook; for (int j = 1 + 1; j < subjects.Count; j++) { if (m == subjects[j].Modulhandbook) { Session["Message"] = true; CheckforMessage("Ein Modul kann nicht zweimal im gleichen Modulhandbuch auftreten!"); return(false); } } } } return(true); }
void Application_Start(object sender, EventArgs e) { // Code, der beim Anwendungsstart ausgeführt wird BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterOpenAuth(); // Add Administrator. if (!Roles.RoleExists("Administrator")) { Roles.CreateRole("Administrator"); } if (Membership.GetUser("Admin") == null) { Membership.CreateUser("Admin", "Pa$$word", "*****@*****.**"); Roles.AddUserToRole("Admin", "Administrator"); Roles.AddUserToRole("Admin", "Freigabeberechtigter"); Roles.AddUserToRole("Admin", "Modulverantwortlicher"); Roles.AddUserToRole("Admin", "Koordinator"); Roles.AddUserToRole("Admin", "User"); } if (Membership.GetUser("haldeigosh") == null) { Membership.CreateUser("haldeigosh", "haldeigosh", "*****@*****.**"); Roles.AddUserToRole("haldeigosh", "Administrator"); } if (!Roles.RoleExists("User")) { Roles.CreateRole("User"); } if (!Roles.RoleExists("Freigabeberechtigter")) { Roles.CreateRole("Freigabeberechtigter"); } if (Membership.GetUser("Freigeber") == null) { Membership.CreateUser("Freigeber", "Freigeber", "*****@*****.**"); Roles.AddUserToRole("Freigeber", "Freigabeberechtigter"); } if (!Roles.RoleExists("Modulverantwortlicher")) { Roles.CreateRole("Modulverantwortlicher"); } if (Membership.GetUser("Modulverantwortlicher1") == null) { Membership.CreateUser("Modulverantwortlicher1", "Modulverantwortlicher1", "*****@*****.**"); Roles.AddUserToRole("Modulverantwortlicher1", "Modulverantwortlicher"); } if (Membership.GetUser("Modulverantwortlicher2") == null) { Membership.CreateUser("Modulverantwortlicher2", "Modulverantwortlicher2", "*****@*****.**"); Roles.AddUserToRole("Modulverantwortlicher2", "Modulverantwortlicher"); } if (!Roles.RoleExists("Koordinator")) { Roles.CreateRole("Koordinator"); } if (Membership.GetUser("Koordinator") == null) { Membership.CreateUser("Koordinator", "Koordinator", "*****@*****.**"); Roles.AddUserToRole("Koordinator", "Koordinator"); } //Neuer Datenbank initializer, der mehrere Testdaten anlegt Database.SetInitializer(new ModulhandbookInitializer()); using (var db = new ModulhandbookContext()) { var x = db.Modules.ToList(); } }