public IEnumerable <Dish> GetFavouriteDishesByCustomer() { string userJWTId = User.FindFirst("id")?.Value; Customer customer = db.GetCustomer(userJWTId); if (customer == null) { return(dishRepository.GetEntityList()); } List <int> favouriteDishesIds = db.GetFavouriteDishByCustomer(customer.Id) .Select(x => x.DishId).ToList(); List <Dish> favouriteDishes = new List <Dish>(); for (int i = 0; i < favouriteDishesIds.Count(); i++) { favouriteDishes.Add(dishRepository.GetEntity(favouriteDishesIds[i])); favouriteDishes.Last().Ingredient = null; favouriteDishes.Last().Menu = null; } return(favouriteDishes.AsEnumerable()); }
public IEnumerable <Dish> Get() { return(db.GetEntityList()); }