Exemple #1
0
        // Löschung des Lehrstuhleintrags als
        // import: lehrstuhleintragid
        // export: lehrstuhleintraegeModel
        // redirect auf error view, falls keine authorizierung vorliegt.
        // GET: LehrstuhlEintraege/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var userId = User.Identity.GetUserId();
            int idauth = (int)id;

            if (AuthCheck.VerantLehr(idauth, userId) || AuthCheck.AutorLE(idauth, userId) || User.IsInRole("Admin"))
            {
                LehrstuhlEintraege lehrstuhlEintraege = db.LehrstuhlEintraeges.Find(id);
                if (lehrstuhlEintraege == null)
                {
                    return(HttpNotFound());
                }
                return(View(lehrstuhlEintraege));
            }

            return(RedirectToAction("Unauthorized", "Error"));
        }
Exemple #2
0
        // Liefert eine Liste von Lehrstuhleinträgen. Diese List enthält nur die Einträge eines bestimmten Lehrstuhls, falls
        // eine lehrstuhlID übergeben wird, ansonsten werden die Einträge aller lehrstühle zurückgegeben
        // (Import optional: lehrstuhlID, Export: lehrstuhlEinträge List)
        // GET: LehrstuhlEintraege
        public ActionResult Index(int?lehrstuhlid)
        {
            List <LehrstuhlEintraege> entries   = new List <LehrstuhlEintraege>();
            List <Person>             zuordnung = new List <Person>();
            String  userid = "";
            Boolean ok     = false;                        // für prüfung auf mitgliedschaft

            Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher
            Boolean[] autor          = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein autor
            var       userId         = User.Identity.GetUserId();

            foreach (Lehrstuhl l in db.Lehrstuhls)
            {
                // Wenn der lehrstuhl privat ist, dann prüfe, ob User mitarbeiter des lehrstuhls ist
                // falls ja oder lehrstuhl nicht privat, dann OK und weiter (Admin sieht alles immer)
                if (l.lehrstuhlid == lehrstuhlid && l.privat == true && !User.IsInRole("Admin"))
                {
                    // hier werden PRIVATEN alle lehrstühle ausgeschlossen, in denen der User nicht mitarbeiter ist
                    ok = false;

                    foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls)
                    {
                        if (ml.lehrstuhlid == l.lehrstuhlid && ml.userid == userId)
                        {
                            ok = true;
                        }
                    }
                }
                else
                {
                    ok = true;
                }
            }


            if (ok)
            {
                if (lehrstuhlid == null)
                {
                    return(View(db.LehrstuhlEintraeges.ToList()));
                }
                else
                {
                    foreach (LehrstuhlEintraege le in db.LehrstuhlEintraeges)
                    {
                        // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf
                        autor[le.id] = AuthCheck.AutorLE(le.id, userId);
                        verantwortlich[le.lehrstuhlid] = AuthCheck.VerantLehr(le.lehrstuhlid, userId);

                        if (le.lehrstuhlid == lehrstuhlid)
                        {
                            foreach (Person person in db.Person)
                            {
                                if (person.id == le.autor)
                                {
                                    ViewBag.mail = person.AspNetUsers.Email;
                                    le.autor     = HelpFunctions.GetDisplayName(person.id);
                                    userid       = person.id;
                                }
                            }
                            // zuordnungstabelle für verlinkung erstellen
                            Person el = new Person();
                            el.id   = userid;
                            el.name = le.autor;

                            zuordnung.Add(el);

                            entries.Add(le);
                        }
                    }

                    ViewBag.zuordnung      = zuordnung;
                    ViewBag.autor          = autor;
                    ViewBag.verantwortlich = verantwortlich;

                    // Bezeichnung des lehrstuhls in View übergeben
                    foreach (Lehrstuhl le in db.Lehrstuhls)
                    {
                        if (le.lehrstuhlid == lehrstuhlid)
                        {
                            ViewBag.bezeichnung = le.bezeichnung;
                        }
                    }
                }
            }

            return(View(entries.ToList()));
        }
Exemple #3
0
        ////////////////////////
        ///  Lehrstuhleinträge
        ////////////////////


        // Index View der Newsfeed Seite, die das NewsfeedModel verwendet
        // Import: keine
        // Export: NewsfeedModel + diverse ViewBags
        public ActionResult Index()
        {
            List <NewsFeedModel> list      = new List <NewsFeedModel>();
            List <Person>        zuordnung = new List <Person>();

            Boolean[] lverantwortlich = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl lehrstuhlid kein Verantwortlicher
            Boolean[] lautor          = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl lehrstuhlid kein autor
            Boolean   abonniert       = false;
            var       userId          = User.Identity.GetUserId();

            // Alle abonnierten Lehrstuhleinträge und relevanten (=mitglied) lehrstuhleinträge auslesen
            foreach (LehrstuhlEintraege le in db.LehrstuhlEintraeges)
            {
                // Signal an Frontend, ob User auch autor ist und bearbeiten/löschen darf
                lautor[le.id] = AuthCheck.AutorLE(le.id, userId);

                // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf
                lverantwortlich[le.lehrstuhlid] = AuthCheck.VerantLehr(le.lehrstuhlid, userId);


                // prüfen, ob user mitarbeiter des lehrstuhls ist oder diesen abonniert hat
                foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls)
                {
                    if (ml.lehrstuhlid == le.lehrstuhlid && ml.userid == userId || User.IsInRole("Admin"))
                    {
                        abonniert = true;
                    }
                }

                foreach (AbonnentenLehrstuhl al in db.AbonnentenLehrstuhls)
                {
                    if (al.lehrstuhlid == le.lehrstuhlid && al.userid == userId || User.IsInRole("Admin"))
                    {
                        abonniert = true;
                    }
                }

                // Userid richtig darstellen
                foreach (Person person in db.Person)
                {
                    if (person.id == le.autor)
                    {
                        le.autor = HelpFunctions.GetFeedDisplayName(person.id);

                        // zuordnungstabelle für verlinkung erstellen
                        zuordnung.Add(new Person
                        {
                            id   = person.id,
                            name = le.autor
                        });
                    }
                }


                ViewBag.lautor          = lautor;
                ViewBag.lverantwortlich = lverantwortlich;

                if (abonniert)
                {
                    list.Add(new NewsFeedModel
                    {
                        id         = le.id,
                        entityid   = le.lehrstuhlid,
                        datum      = le.datum,
                        autor      = le.autor,
                        inhalt     = le.inhalt,
                        label1     = le.label1,
                        label2     = le.label2,
                        label3     = le.label3,
                        label4     = le.label4,
                        label5     = le.label5,
                        typ        = "l",
                        entityname = HelpFunctions.GetLehrstuhlName(le.lehrstuhlid)
                    });
                }

                abonniert = false;
            }

            ////////////////////////
            ///  Gruppeneinträge
            ////////////////////

            Boolean[] verantwortlich = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein Verantwortlicher
            Boolean[] autor          = new Boolean[10000]; // Index gruppenid, Eintrag false -> Gruppe gruppenid kein autor
            Boolean   mitglied       = false;

            foreach (GruppenEintraege le in db.GruppenEintraeges)
            {
                // Signal an Frontend, ob User auch autor ist und bearbeiten/löschen darf
                autor[le.id] = AuthCheck.AutorGE(le.id, userId);

                // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf
                verantwortlich[le.gruppenid] = AuthCheck.VerantGr(le.gruppenid, userId);

                // prüfen, ob user mitglied der gruppe ist
                foreach (MitgliederGruppe mg in db.MitgliederGruppes)
                {
                    if (mg.gruppenid == le.gruppenid && mg.userid == userId || User.IsInRole("Admin"))
                    {
                        mitglied = true;
                    }
                }


                // Userid richtig darstellen
                foreach (Person person in db.Person)
                {
                    if (person.id == le.autor)
                    {
                        le.autor = HelpFunctions.GetFeedDisplayName(person.id);

                        // zuordnungstabelle für verlinkung erstellen
                        zuordnung.Add(new Person
                        {
                            id   = person.id,
                            name = le.autor
                        });
                    }
                }


                ViewBag.autor          = autor;
                ViewBag.verantwortlich = verantwortlich;

                if (mitglied)
                {
                    list.Add(new NewsFeedModel
                    {
                        id         = le.id,
                        entityid   = le.gruppenid,
                        datum      = le.datum,
                        autor      = le.autor,
                        inhalt     = le.inhalt,
                        label1     = le.label1,
                        label2     = le.label2,
                        label3     = le.label3,
                        label4     = le.label4,
                        label5     = le.label5,
                        typ        = "g",
                        entityname = HelpFunctions.GetGruppenName(le.gruppenid)
                    });
                }
                mitglied = false;
            }



            // Gruppen und Lehrstühle müssen in eienr Partial View angezeigt werden!
            // var lehrstuehle = db.Lehrstuhls.ToList();
            ViewBag.zuordnung = zuordnung.Distinct();

            return(View(list));
        }
        // Gibt eine Liste mit allen vorhandenen Lehrstühlen zurück
        // import: keine
        // export: lehrstuhlmodel
        // GET: Lehrstuhl
        public ActionResult Index()
        {
            List <Lehrstuhl> entries   = new List <Lehrstuhl>();
            List <Person>    zuordnung = new List <Person>();

            Boolean[] verantwortlich = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl kein Verantwortlicher
            Boolean[] mitarbeiter    = new Boolean[10000]; // Index lehrstuhlid, Eintrag false -> lehrstuhl kein mitarbeiter
            Boolean   ok             = false;              // mitarbeiter private gruppe
            var       userId         = User.Identity.GetUserId();

            foreach (Lehrstuhl lehrstuhl in db.Lehrstuhls)
            {
                // Wenn der lehrstuhl privat ist, dann prüfe, ob User mitarbeiter ist
                // falls ja oder lehrstuhl nicht privat, dann OK und weiter (Admin sieht alles immer)

                // Signal an Frontend, ob User auch Verantwortlicher ist und somit bearbeiten/löschen darf
                verantwortlich[lehrstuhl.lehrstuhlid] = AuthCheck.VerantLehr(lehrstuhl.lehrstuhlid, userId);
                mitarbeiter[lehrstuhl.lehrstuhlid]    = AuthCheck.MitarbeiterLehr(lehrstuhl.lehrstuhlid, userId);

                if (lehrstuhl.privat == true && !User.IsInRole("Admin"))
                {
                    // hier werden PRIVATEN alle lehrstühle ausgeschlossen, in denen der User nicht Mitarbeiter ist
                    ok = false;


                    foreach (MitarbeiterLehrstuhl ml in db.MitarbeiterLehrstuhls)
                    {
                        if (ml.lehrstuhlid == lehrstuhl.lehrstuhlid && ml.userid == userId)
                        {
                            ok = true;
                        }
                    }
                }
                else
                {
                    ok = true;
                }

                if (ok)
                {
                    foreach (Person person in db.Person)
                    {
                        if (person.id == lehrstuhl.verantwortlicher)
                        {
                            lehrstuhl.verantwortlicher = HelpFunctions.GetDisplayName(person.id);

                            // zuordnungstabelle für verlinkung erstellen
                            Person el = new Person();
                            el.id   = person.id;
                            el.name = lehrstuhl.verantwortlicher;

                            zuordnung.Add(el);
                        }
                    }

                    entries.Add(lehrstuhl);
                }


                // Um abonnieren/deabonnieren zu kennzeichnen, ViewBag mit allen Abos des Users an Frontend senden
                List <AbonnentenLehrstuhl> list = new List <AbonnentenLehrstuhl>();

                // Alle Abos des angemeldeten Users suchen
                foreach (AbonnentenLehrstuhl al in db.AbonnentenLehrstuhls)
                {
                    if (al.userid == userId)
                    {
                        list.Add(al);
                    }
                }

                ViewBag.abos = list;
            }



            ViewBag.mitarbeiter    = mitarbeiter;
            ViewBag.verantwortlich = verantwortlich;
            ViewBag.zuordnung      = zuordnung;


            return(View(entries));
        }