コード例 #1
0
ファイル: ReviewsController.cs プロジェクト: JWroe/OdeToFood
 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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #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);
 }
コード例 #8
0
ファイル: OdeToFoodDB.cs プロジェクト: CasperKnobbe/OdeToFood
 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();
     };
 }
コード例 #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);
        }
コード例 #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);
        }