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 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 müssen mindestens ein Fach für das Modul festlegen!");
                return(false);
            }

            return(true);
        }
        /// <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);
        }
Esempio n. 3
0
 public static List <ModulPartDescription> getDefaultDescriptions()
 {
     return(new List <ModulPartDescription>()
     {
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameNum(), Description = GlobalNames.getModulNameNumDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameText(), Description = GlobalNames.getModulNameTextDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameECTS(), Description = GlobalNames.getModulNameECTSDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameWeekHours(), Description = GlobalNames.getModulNameWeekHoursDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLanguage(), Description = GlobalNames.getModulNameLanguageDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameTurnus(), Description = GlobalNames.getModulNameTurnusDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLecturer(), Description = GlobalNames.getModulNameLecturerDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameFitsInStudy(), Description = GlobalNames.getModulNameFitsInStudyDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameReqContent(), Description = GlobalNames.getModulNameReqContentDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameEducation(), Description = GlobalNames.getModulNameEducationDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameContent(), Description = GlobalNames.getModulNameContentDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameLiterature(), Description = GlobalNames.getModulNameLiteratureDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameTeaching(), Description = GlobalNames.getModulNameTeachingDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameEffort(), Description = GlobalNames.getModulNameEffortDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameMark(), Description = GlobalNames.getModulNameMarkDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameReqFormal(), Description = GlobalNames.getModulNameReqFormalDesc(), IsNeeded = true
         },
         new ModulPartDescription()
         {
             Name = GlobalNames.getModulNameGrade(), Description = GlobalNames.getModulNameGradeDesc(), IsNeeded = true
         }
     });
 }