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([Bind(Include = "Id,Name,City,Country")] Restaurant restaurant) { if (ModelState.IsValid) { db.Restaurants.Add(restaurant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restaurant)); }
public ActionResult Create(Restaurant restaurant) { if (ModelState.IsValid) { db.Restaurants.Add(restaurant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(restaurant)); }
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 Create(int restaurantID, Review newReview) { try { var restaurant = _db.Restaurants.Single(r => r.ID == restaurantID); restaurant.Reviews.Add(newReview); _db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }