public ActionResult Edit([Bind(Include = "Id,Name,City,Country")] Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Пример #2
0
 public ActionResult Edit(Restaurant restaurant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(restaurant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(restaurant));
 }
Пример #3
0
 public ActionResult Edit(RestaurantReview review)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(review).State = System.Data.Entity.EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index", new { id = review.RestaurantID }));
     }
     return(View(review));
 }
 public ActionResult Edit([Bind(Exclude = "ReviewerName")] RestrauntReview review)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(review).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index", new { id = review.RestaurantId }));
     }
     return(View(review));
 }
Пример #5
0
 // exclude works as a black list. using it assures that the action won't receive the field called reviewername
 // I can also create a personalized view model and it will only have the parameters I expect from the user
 //public ActionResult Edit([Bind(Exclude="ReviewerName")] RestaurantReview review)
 public ActionResult Edit(RestaurantReview review)
 {
     if (ModelState.IsValid)
     {
         // entry keeps track of a record. tells to _db that is not a new record
         // treat it as if I am adding new data inside
         _db.Entry(review).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index", new { id = review.RestaurantId }));
     }
     return(View(review));
 }