Example #1
0
        public ActionResult EditPozwolenie(int id, Pozwolenie pozwolenieToEdit)
        {
            if ((!User.Identity.IsAuthenticated && !User.IsInRole("Administrator")) || (!User.Identity.IsAuthenticated && !User.IsInRole("Pracownik")))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                _db.Entry(pozwolenieToEdit).State = System.Data.Entity.EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Pozwolenia"));
            }
            return(View(pozwolenieToEdit));
        }
Example #2
0
        public ActionResult CreatePozwolenie(Pozwolenie newPozwolenie)
        {
            if ((!User.Identity.IsAuthenticated && !User.IsInRole("Administrator")) || (!User.Identity.IsAuthenticated && !User.IsInRole("Pracownik")))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid && (newPozwolenie.idProjektu != null) && !String.IsNullOrEmpty(newPozwolenie.nazwa))
            {
                _db.Pozwolenia.Add(newPozwolenie);
                _db.SaveChanges();
                return(RedirectToAction("Pozwolenia"));
            }
            else
            {
                return(View(newPozwolenie));
            }
        }