Example #1
0
        public ActionResult Autorisieren(int?id)
        {
            if (Session["userID"] == null)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                var log = new Logs();
                log.Aktion   = "Entry with ID " + id + "authorized by Admin";
                log.Admin_ID = (int)Session["userID"];
                log.IP       = Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
                log.Zeit     = DateTime.Now;
                db.Logs.Add(log);

                Eintraege eintraege = db.Eintraege.Find(id);
                db.Eintraege.Find(id).Autorisiert_ID = (int)Session["userID"];
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            Eintraege eintraege = db.Eintraeges.Find(id);

            db.Eintraeges.Remove(eintraege);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Eintrag_Id,Vorname,Nachname,Datum,Kommentar")] Eintraege eintraege)
 {
     if (ModelState.IsValid)
     {
         db.Entry(eintraege).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(eintraege));
 }
        public ActionResult Create([Bind(Include = "Eintrag_Id,Vorname,Nachname,Datum,Kommentar")] Eintraege eintraege)
        {
            if (ModelState.IsValid)
            {
                eintraege.Eintrag_Id = Guid.NewGuid();
                db.Eintraeges.Add(eintraege);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eintraege));
        }
        // GET: Eintraeges/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eintraege eintraege = db.Eintraeges.Find(id);

            if (eintraege == null)
            {
                return(HttpNotFound());
            }
            return(View(eintraege));
        }
Example #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            var log = new Logs();

            log.Aktion   = "Entry with ID " + id + "deleted by Admin";
            log.Admin_ID = (int)Session["userID"];
            log.IP       = Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
            log.Zeit     = DateTime.Now;
            db.Logs.Add(log);

            Eintraege eintraege = db.Eintraege.Find(id);

            db.Eintraege.Remove(eintraege);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #7
0
        // GET: Eintraeges/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["userID"] == null)
            {
                return(RedirectToAction("index"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eintraege eintraege = db.Eintraege.Find(id);

            if (eintraege == null)
            {
                return(HttpNotFound());
            }
            return(View(eintraege));
        }
Example #8
0
        public ActionResult Edit([Bind(Include = "Id,IP,Name,Besuchsdatum,Kommentar,Autorisiert_ID")] Eintraege eintraege)
        {
            if (ModelState.IsValid)
            {
                var log = new Logs();
                log.Aktion   = "Entry with ID " + eintraege.Id + " edited by Admin";
                log.Admin_ID = (int)Session["userID"];
                log.IP       = Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
                log.Zeit     = DateTime.Now;
                db.Logs.Add(log);

                db.Entry(eintraege).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.Autorisiert_ID = new SelectList(db.Admin, "Id", "Name", eintraege.Autorisiert_ID);
            return(View(eintraege));
        }
Example #9
0
 public ActionResult Autorisieren(int?id)
 {
     if (Session["isAdmin"] == null)
     {
         return(RedirectToAction("Index"));
     }
     else
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Eintraege eintraege = db.Eintraeges.Find(id);
         db.Eintraeges.Find(id).Autorisiert_ID = (int)Session["isAdmin"];
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
        public ActionResult Authorize(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eintraege eintraege = db.Eintraeges.Find(id);

            if (eintraege == null)
            {
                return(HttpNotFound());
            }
            eintraege.Autorisiert_ID = (int)Session["userID"];
            int lol = (int)Session["userID"];

            db.Entry(eintraege).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #11
0
        public ActionResult Create([Bind(Include = "Id,IP,Name,Besuchsdatum,Kommentar,Autorisiert_ID")] Eintraege eintraege)
        {
            if (ModelState.IsValid)
            {
                // log eintrag erstellen
                var log = new Logs();
                log.Aktion = "Created Entry by " + eintraege.Name;
                log.IP     = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.GetValue(0).ToString();
                log.Zeit   = DateTime.Now;
                db.Logs.Add(log);

                db.Eintraege.Add(eintraege);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Autorisiert_ID = new SelectList(db.Admin, "Id", "Name", eintraege.Autorisiert_ID);
            return(View(eintraege));
        }
Example #12
0
        // GET: Eintraeges/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["userID"] == null)
            {
                return(RedirectToAction("index"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Eintraege eintraege = db.Eintraege.Find(id);

            if (eintraege == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Autorisiert_ID = new SelectList(db.Admin, "Id", "Name", eintraege.Autorisiert_ID);
            return(View(eintraege));
        }