Example #1
0
        public ActionResult Create([Bind(Include = "id,nazwa")] Firma firma)
        {
            if (ModelState.IsValid)
            {
                db.Firmas.Add(firma);
                db.SaveChanges();
                return(RedirectToAction("Index", "Widok"));
            }

            return(View(firma));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "id,nazwa,id_zasob")] Poziom_uprawnien poziom_uprawnien)
        {
            if (ModelState.IsValid)
            {
                db.Poziom_uprawnien.Add(poziom_uprawnien);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_zasob = new SelectList(db.Zasobs, "id", "nazwa", poziom_uprawnien.id_zasob);
            return(View(poziom_uprawnien));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "id,nazwa,id_zasob")] Nazwa_zasobu nazwa_zasobu)
        {
            if (ModelState.IsValid)
            {
                db.Nazwa_zasobu.Add(nazwa_zasobu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_zasob = new SelectList(db.Zasobs, "id", "nazwa", nazwa_zasobu.id_zasob);
            return(View(nazwa_zasobu));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "id,id_firma,nazwa")] Zasob zasob)
        {
            if (ModelState.IsValid)
            {
                db.Zasobs.Add(zasob);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_firma = new SelectList(db.Firmas, "id", "nazwa", zasob.id_firma);
            return(View(zasob));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "id,imie,nazwisko,id_firma")] Pracownik pracownik)
        {
            if (ModelState.IsValid)
            {
                db.Pracowniks.Add(pracownik);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_firma = new SelectList(db.Firmas, "id", "nazwa", pracownik.id_firma);
            return(View(pracownik));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "id,id_pracownik,id_zasob,id_nazwa_zasobu,id_poziom,data_utworzenia,data_zatwierdzenia,data_usunięcia,zatwierdzil,utworzyl,usunal")] Uprawnienie uprawnienie)
        {
            //if (ModelState.IsValid)
            //{
            db.Uprawnienies.Add(uprawnienie);
            uprawnienie.data_utworzenia = DateTime.Now;
            uprawnienie.utworzyl        = User.Identity.GetUserName();

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                // Retrieve the error messages as a list of strings.
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);

                // Join the list to a single string.
                var fullErrorMessage = string.Join("; ", errorMessages);

                // Combine the original exception message with the new one.
                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);

                // Throw a new DbEntityValidationException with the improved exception message.
                throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
            }


            return(RedirectToAction("Index"));

            //}

            //ViewBag.id_poziom = new SelectList(db.Zasobs.Where(g => g.id == i).ToList(), "nazwa", "nazwa");
            ViewBag.id_poziom    = new SelectList(db.Poziom_uprawnien, "id", "nazwa", uprawnienie.id_poziom);
            ViewBag.id_pracownik = new SelectList(db.Pracowniks, "id", "nazwisko", uprawnienie.id_pracownik);

            ViewBag.id_zasob        = new SelectList(db.Zasobs, "id", "nazwa", uprawnienie.id_zasob);
            ViewBag.id_nazwa_zasobu = new SelectList(db.Nazwa_zasobu, "id", "nazwa", uprawnienie.id_nazwa_zasobu);
            return(View(uprawnienie));
        }