Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id,Name,Year,Publisher,Price")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(book));
 }
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
Ejemplo n.º 3
0
 public ActionResult CategoryEditForm(Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.Id <= 0)
         {
             dc.Categories.Add(category);
         }
         else
         {
             dc.Entry(category).State = EntityState.Modified;
         }
         dc.SaveChanges();
         return(RedirectToAction("CategoryListForm"));
     }
     return(View(category));
 }