//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); }
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); }
//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); }