コード例 #1
0
 //Add
 public Entity.Restaurant AddRestaurant(Entity.Restaurant restaurant)
 {
     context.Restaurants.Add(restaurant);
     Save();
     //foreach (RestaurantCuisine restaurantCuisine in restaurant.RestaurantCuisine.ToList())
     //   AddCuisineType(restaurant.Id ,restaurantCuisine.CuisineType);
     return(restaurant);
 }
コード例 #2
0
        public async Task <Entity.Restaurant> GetRestaurants(int restaurantId)
        {
            Entity.Restaurant restaurant = await context.Restaurants.Where(r => r.Id == restaurantId)
                                           .Include(r => r.Ratings)
                                           .Include(r => r.RestaurantCuisine)
                                           .ThenInclude(rc => rc.CuisineType)
                                           .FirstOrDefaultAsync();

            return(restaurant);
        }
コード例 #3
0
        //private static readonly IMapper _mapper;
        //public GetData(IMapper mapper)
        //{
        //    _mapper = mapper ??
        //           throw new ArgumentNullException(nameof(mapper));
        //}
        public static List <CuisineType> GetCuisineTypeFromResCuis(
            this Entity.Restaurant restaurant)
        {
            List <CuisineType> cuisineTypes = new List <CuisineType>();

            foreach (RestaurantCuisine restaurantCuisine in restaurant.RestaurantCuisine)
            {
                cuisineTypes.Add(restaurantCuisine.CuisineType);
            }

            return(cuisineTypes);
        }