コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// Saves the Modul with the given Modulstate und version number 1+n where n is the number, of the latest version
        /// </summary>
        /// <param name="state"></param>
        private void SaveChanges(ModulState state)
        {
            if (CheckDescriptions())
            {
                int indexOfCurrentModulpunkt = GetCurrentIndex();
                List <ModulPartDescription> modulpartdescriptions = GetModulpartDescriptions();
                List <Subject> subjects = GetSubjects();
                modulpartdescriptions[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
                modulpartdescriptions[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
                if (!CommentTextBox.Text.Trim().Equals(""))
                {
                    modulpartdescriptions[indexOfCurrentModulpunkt].Comment = CommentTextBox.Text;
                }



                var          mu    = System.Web.Security.Membership.GetUser();
                Guid         user  = (Guid)mu.ProviderUserKey;
                Modul        modul = GetModulByQuerystring();
                ArchiveLogic al    = new ArchiveLogic();
                JobLogic     jl    = new JobLogic();

                //create the new Modulpartdescriptions
                List <ModulPartDescription> mpdList = new List <ModulPartDescription>();
                foreach (ModulPartDescription m in modulpartdescriptions)
                {
                    ModulPartDescription toAdd = new ModulPartDescription()
                    {
                        IsNeeded    = m.IsNeeded,
                        Description = m.Description,
                        Comment     = m.Comment,
                        Name        = m.Name
                    };
                    mpdList.Add(toAdd);
                }

                Modul newModule = al.CreateModul(mpdList, state, modul.Owner, user, DateTime.Now, subjects, modul.Version + 1);

                Session["Message"] = true;
                if (newModule != null)
                {
                    CheckforMessage("Neue Version Erstellt!");
                    jl.CreateNewJob(state, mpdList, newModule, user);
                }
                else
                {
                    CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
                }
            }
        }
コード例 #3
0
        private bool DescriptionDone(ModulPartDescription mpd, String defaultText)
        {
            if (mpd.Description.Trim().Equals(""))
            {
                return(false);
            }
            if (mpd.Description.ToUpper().Trim() == defaultText.ToUpper().Trim())
            {
                return(false);
            }
            if (mpd.Name.Equals("ECTS-Punkte") || mpd.Name.Equals("Semesterwochenstunden"))
            {
                String text = mpd.Description;
                double Num;
                bool   isNum = double.TryParse(text, out Num);

                if (!isNum)
                {
                    return(false);
                }
            }
            return(true);
        }