Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,CatalogId,HolderId,Iso,Pin,StartDate,EndDate,CreatedDate,ModifiedDate,StatusType,StatusDate")] Card card)
        {
            if (ModelState.IsValid)
            {
                db.Cards.Add(card);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CatalogId = new SelectList(db.Catalogs, "Id", "DisplayName", card.CatalogId);
            ViewBag.HolderId  = new SelectList(db.Designees, "Id", "LastName", card.HolderId);
            return(View(card));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "DisplayName")] Catalog catalog)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Catalogs.Add(catalog);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes.  Try again, and if the problem persists see you system administrator.");
            }

            return(View(catalog));
        }