Esempio n. 1
0
        public ActionResult CreateUsingProcedure([Bind(Include = "IdWydawnictwo, Nazwa")] Wydawnictwo wydawnictwo)
        {
            if (ModelState.IsValid)
            {
                db.Wydawnictwoes.Add(wydawnictwo);
                try
                {
                    db.DodajWydawnictwo(wydawnictwo.IdWydawnictwo, wydawnictwo.Nazwa);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane wydawnictwa!";
                    }
                    else
                    {
                        message = e.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    return(View(wydawnictwo));
                }
                return(RedirectToAction("Index"));
            }
            return(View(wydawnictwo));
        }