Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public ActionResult Create(RestaurantReview review)
 {
     if(ModelState.IsValid)
     {
         _db.Reviews.Add(review);
         _db.SaveChanges();
         return RedirectToAction("Index", new {id =review.RestaurantId });
     }
     return View(review);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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();
     };
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }