Esempio n. 1
0
        public ActionResult EditCatalog(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var catalogToUpdate = db.Catalogs.Find(id);

            if (TryUpdateModel(catalogToUpdate, "",
                               new string[] { "DisplayName" }))
            {
                try
                {
                    // IF changes were made then update the Modified Date property
                    if (db.Entry(catalogToUpdate).State == EntityState.Modified)
                    {
                        catalogToUpdate.ModifiedDate = System.DateTime.Now;
                    }

                    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 your system administrator.");
                }
            }
            return(View(catalogToUpdate));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "Id,CatalogId,HolderId,Iso,Pin,StartDate,EndDate,CreatedDate,ModifiedDate,StatusType,StatusDate")] Card card)
 {
     if (ModelState.IsValid)
     {
         db.Entry(card).State = EntityState.Modified;
         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));
 }