public ActionResult Delete(int id)
        {
            Restaurants thisPlace = Restaurants.Find(id);

            thisPlace.Delete();

            return(RedirectToAction("ViewAll"));
        }
示例#2
0
        public void ChangeDish(Dish dish)
        {
            var dbDish = Dishes
                         .Include(x => x.Restaurant)
                         .Single(x => x.Id == dish.Id);

            Entry(dbDish).CurrentValues.SetValues(dish);
            dbDish.Restaurant = Restaurants.Find(dish.Restaurant.Id);
        }
示例#3
0
        private void ValidateRestUpdate(int expectedId, string expectedName, int expectedCuisine, int expectedCreatedById, int expectedUpdatedById, UpdateRestaurantRequestModel restToUpdate)
        {
            var actualRest = Restaurants.Find(r => r.Id == restToUpdate.RestaurantId);

            Assert.IsNotNull(actualRest, "Update restaurant not found");
            Assert.AreEqual(expectedId, actualRest.Id, "Restaurant ID");
            Assert.AreEqual(expectedName, actualRest.Name, "Restaurant Name");
            Assert.AreEqual(expectedCuisine, actualRest.Cuisine.Id, "Restaurant CuisineId");
            Assert.AreEqual(expectedCreatedById, actualRest.CreatedBy, "Restaurant Created By");
            Assert.AreEqual(expectedUpdatedById, actualRest.UpdatedBy, "Restaurant Updated by");
        }
        private void ValidateRestaurant(int expectedRestId, string expectedName, Cuisine expectedCuisine,
                                        IEnumerable <Review> expectedReviews, double expectedAverageRating, int expectedReviewCount)
        {
            var actualRest = Restaurants.Find(r => r.Id == expectedRestId);

            Assert.IsNotNull(actualRest, "Update restaurant not found");
            Assert.AreEqual(expectedRestId, actualRest.Id, "Restaurant ID");
            Assert.AreEqual(expectedName, actualRest.Name, "Restaurant Name");
            Assert.AreEqual(expectedCuisine.Id, actualRest.Cuisine.Id, "Restaurant CuisineId");

            var reviews       = expectedReviews.ToArray();
            var actulaReviews = actualRest.Reviews.ToArray();

            for (var i = 0; i < reviews.Length; i++)
            {
                Assert.AreEqual(reviews[i], actulaReviews[i]);
            }

            Assert.AreEqual(expectedAverageRating, actualRest.AverageRating);
            Assert.AreEqual(expectedReviewCount, actualRest.ReviewCount);
        }