Ejemplo n.º 1
0
        /// <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>
        /// 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!");
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// creates a job depending on the modulstate and write it into the db
        /// </summary>
        /// <param name="state">modulstate after which the job is created</param>
        /// <param name="mpdList">needed for job parameters</param>
        /// <param name="module">needed for the module id</param>
        /// <param name="user">the job creater</param>
        public void CreateNewJob(ModulState state, List <ModulPartDescription> mpdList, Modul module, Guid user)
        {
            String       name = null, text = null;
            String       modulname = getModulname(mpdList);
            ArchiveLogic logic     = new ArchiveLogic();
            Guid         executer  = new Guid();

            if (state.Equals(ModulState.created))
            {
                name = "Das Modul " + modulname + " wurde erstellt";
                text = "Bitte kontrollieren.";
                MembershipUser Modulverantwortlicher1 = Membership.GetUser("Koordinator");
                executer = new Guid(Modulverantwortlicher1.ProviderUserKey.ToString());
            }
            else if (state.Equals(ModulState.waitingForFreigeber))
            {
                name = "Das Modul " + modulname + " wurde vom Koordinator kontrolliert";
                text = "Bitte freigeben";
                MembershipUser Modulverantwortlicher1 = Membership.GetUser("Freigeber");
                executer = new Guid(Modulverantwortlicher1.ProviderUserKey.ToString());
            }
            else if (state.Equals(ModulState.abgelehnt))
            {
                name = "Das Modul " + modulname + " wurde vom " + user.ToString() + " abgelehnt";
                text = "TODO: hier soll die begründung vom koordinator bzw freigabeberehtigtem rein";
                MembershipUser Modulverantwortlicher1 = Membership.GetUser("Freigeber");
                executer = new Guid(Modulverantwortlicher1.ProviderUserKey.ToString());
            }

            Job job = new Job()
            {
                JobCreated   = System.DateTime.Now,
                JobCreatedBy = user,
                ModulID      = module.ModulID,
                Executer     = executer,
                Name         = name,
                Text         = text,
            };

            context.Jobs.Add(job);
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        //----------------------------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>());
        }