示例#1
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,City,State,Zip,Phone,Web,Country,ImageUrl")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                db.Restaurants.Add(restaurant);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(restaurant));
        }
示例#2
0
        public ActionResult Create(Review review)
        {
            if (ModelState.IsValid)
            {
                review.ReviewDate = DateTime.Now;
                if (Request.IsAuthenticated)
                {
                    review.ReviewerName = User.Identity.GetUserName();
                }

                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = review.RestaurantId }));
            }

            return(View(review));
        }