public IList <MealOutputDTO> GetMeals() { var meals = sellerService.GetMeals(); IList <MealOutputDTO> mealsDTO = new List <MealOutputDTO>(); foreach (var m in meals) { IList <string> garnishiesNames = new List <string>(); if (m.Garnishies != null) { foreach (var g in m.Garnishies) { garnishiesNames.Add(g.Name); } } MealOutputDTO meal = new MealOutputDTO { Id = m.Id, Name = m.Name, GarnishiesName = garnishiesNames, Price = m.Price, Description = m.Description, Days = m.Days }; mealsDTO.Add(meal); } return(mealsDTO); }
public MealOutputDTO GetMealById(int Id) { var meal = this.sellerService.GetMealById(Id); IList <string> garnishiesNames = new List <string>(); if (meal.Garnishies != null) { foreach (var g in meal.Garnishies) { garnishiesNames.Add(g.Name); } } MealOutputDTO mealDTO = new MealOutputDTO() { Id = meal.Id, Name = meal.Name, Description = meal.Description, Price = meal.Price, Days = meal.Days, GarnishiesName = garnishiesNames }; return(mealDTO); }