예제 #1
0
        public ActionResult CreateUsingProcedure([Bind(Include = "IdAutor, Imie, Nazwisko")] Autor autor)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.DodajAutora(autor.IdAutor, autor.Imie, autor.Nazwisko);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

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