コード例 #1
0
        public IActionResult Complete(int ID)
        {
            Restaurant restaurantToComplete = context.Restaurants.First(c => c.ID == ID);

            RateRestaurantViewModel rateRestaurantViewModel = new RateRestaurantViewModel();

            rateRestaurantViewModel.Name  = restaurantToComplete.Name;
            rateRestaurantViewModel.Notes = restaurantToComplete.Notes;
            rateRestaurantViewModel.ID    = restaurantToComplete.ID;

            return(View(rateRestaurantViewModel));
        }
コード例 #2
0
        public IActionResult RateRestaurant(RateRestaurantViewModel rateRestaurantViewModel)
        {
            int        ID = rateRestaurantViewModel.ID;
            Restaurant ratedRestaurant = context.Restaurants.First(C => C.ID == ID);

            ratedRestaurant.Rating           = rateRestaurantViewModel.Rating;
            ratedRestaurant.Notes            = rateRestaurantViewModel.Notes;
            ratedRestaurant.RestaurantStatus = Status.CompletionStatus.Complete;

            context.Restaurants.Update(ratedRestaurant);;

            context.Restaurants.Update(ratedRestaurant);
            context.SaveChanges();

            return(Redirect("/Restaurant"));
        }