Ejemplo n.º 1
0
        public async Task <IHttpActionResult> PutRestaurants(string name, Restaurants restaurants)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (name != restaurants.RestaurantName)
            {
                return(BadRequest());
            }

            db.Entry(restaurants).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                string id = null;
                if (!RestaurantsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "RestaurantID,Name,Phone,Street,City,State,Country,PostalCode")] Restaurant restaurant)
        {
            if (ModelState.IsValid)
            {
                db.Entry(restaurant).State = EntityState.Modified;
                db.SaveChanges();
                return(View("Index"));
            }

            return(View(restaurant));
        }
        public ActionResult Edit([Bind(Include = "ReviewID,Rating,Content,RestaurantID,UserName")] Review review)
        {
            review.ModifiedDate = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(review).State = EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index", new { id = review.RestaurantID }));
            }
            return(View("Index", new { id = review.RestaurantID }));
        }