public ActionResult Create([Bind(Include = "lehrstuhlid,bezeichnung,beschreibung,privat")] Lehrstuhl lehrstuhl)
        {
            if (ModelState.IsValid)
            {
                //angemeldeter User ist Verantwortlicher
                var userId = User.Identity.GetUserId();
                lehrstuhl.verantwortlicher = userId;

                db.Lehrstuhls.Add(lehrstuhl);
                db.SaveChanges();

                // Mitgliedschaft herstellen
                Lehrstuhl neu = db.Lehrstuhls.OrderByDescending(p => p.lehrstuhlid).FirstOrDefault(); // neue lehrstuhlid ermitteln

                MitarbeiterLehrstuhl mg = new MitarbeiterLehrstuhl();
                mg.lehrstuhlid = neu.lehrstuhlid;
                mg.userid      = userId;
                db.MitarbeiterLehrstuhls.Add(mg);

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(lehrstuhl));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Lehrstuhl lehrstuhl = db.Lehrstuhls.Find(id);

            db.Lehrstuhls.Remove(lehrstuhl);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "lehrstuhlid,bezeichnung,beschreibung,verantwortlicher,privat")] Lehrstuhl lehrstuhl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lehrstuhl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(lehrstuhl));
 }
        // Ermöglicht das Bearbeiten eines Lehrstuhls (Import: LehrstuhlID, Export: LehrstuhlModel)
        // import: lehrstuhlid
        // export: lehrstuhlmodel
        // redirect auf error view, falls keine authorizierung vorliegt
        // GET: Lehrstuhl/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

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

            if (AuthCheck.VerantLehr(idauth, userId) || User.IsInRole("Admin"))
            {
                Lehrstuhl lehrstuhl = db.Lehrstuhls.Find(id);
                if (lehrstuhl == null)
                {
                    return(HttpNotFound());
                }
                return(View(lehrstuhl));
            }

            return(RedirectToAction("Unauthorized", "Error"));
        }