public ActionResult Edit(RestaurantReview review) { if (ModelState.IsValid) { db.Entry(review).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index", new { id = review.RestaurantId }); } return View("Edit", review); }
public ActionResult Create(RestaurantReview review) { if(ModelState.IsValid) { _db.Reviews.Add(review); _db.SaveChanges(); return RedirectToAction("Index", new {id =review.RestaurantId }); } return View(review); }
public ActionResult Create(RestaurantReview review) { if (ModelState.IsValid) { _db.RestaurantReviews.Add(review); _db.SaveChanges(); return RedirectToAction("Index", new { id = review.RestaurantId }); } //if we come here that means somethink is wrong! return View(review); }
public ActionResult Create(RestaurantReview review) { if (ModelState.IsValid) { _db.Review.Add(review); _db.SaveChanges(); return RedirectToAction("Index", new {id = review.RestaurantId}); } /*If something went wrong return back to form*/ return View(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); }
public ActionResult Create(RestaurantReview review) { // if this is false, something with the binding went wrong // it checks for all the values in the post and dinds them to the review if (ModelState.IsValid) { _db.Reviews.Add(review); _db.SaveChanges(); return RedirectToAction("Index", new { id = review.RestaurantId }); } return View(review); }
public ActionResult Edit(RestaurantReview review) { if (ModelState.IsValid) { //Entry tells which review to keep tracking in order to //make changes _db.Entry(review).State = EntityState.Modified; _db.SaveChanges(); return RedirectToAction("Index", new {id = review.RestaurantId}); } return View(review); }
public void SetRestaurantReview(RestaurantReview restaurantReview) { using (LINQ_to_SQL_CaspersDatabaseDataContext ctx = new LINQ_to_SQL_CaspersDatabaseDataContext()) { ctx.RestaurantReviews.InsertOnSubmit(new OdeToFood.RestaurantReview { Body = restaurantReview.Body, Id = restaurantReview.Id, Rating = restaurantReview.Rating, RestaurantId = restaurantReview.RestaurantId, }); ctx.SubmitChanges(); }; }
public ViewResult Index() { ViewBag.Message = string.Format("{0}::{1} {2}",RouteData.Values["controller"], RouteData.Values["action"], RouteData.Values["id"]); var model = new RestaurantReview() { Name = "Biba's", Rating =9 }; return View(model); }
public ViewResult Index() { //ViewBag.Message = "default data"; ViewBag.Message = string.Format("{0}::{1} {2}", RouteData.Values["controller"], RouteData.Values["action"], RouteData.Values["id"]); var model = new RestaurantReview() { Name = "Tatyana", Rating = 7 }; return View(model); }