/// <summary>
 /// Saves the new Modul if the input was valid
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void AdoptBtn_Click(object sender, EventArgs e)
 {
     if (CheckDescriptions())
     {
         int indexOfCurrentModulpunkt     = GetCurrentIndex();
         List <ModulPartDescription> list = GetModulpartDescriptions();
         list[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
         list[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
         var            mu        = System.Web.Security.Membership.GetUser();
         Guid           owner     = (Guid)mu.ProviderUserKey;
         ArchiveLogic   al        = new ArchiveLogic();
         JobLogic       jl        = new JobLogic();
         List <Subject> subjects  = GetSubjects();
         Modul          newModule = al.CreateModul(list, ModulState.created, owner, owner, DateTime.Now, subjects, 1);
         Session["Message"] = true;
         if (newModule != null)
         {
             CheckforMessage("Neues Modul erstellt!");
             jl.CreateNewJob(ModulState.created, list, newModule, owner);
         }
         else
         {
             CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
         }
     }
 }
        /// <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!");
                }
            }
        }