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)); }
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)); }