public IActionResult Get(int id) { Dish dish = db.GetEntity(id); if (dish == null) { return(NotFound()); } return(new ObjectResult(dish)); }
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()); }