public IHttpActionResult GetByCategory(TypeofMealCategory category) { MealService mealService = CreateMealService(); var meal = mealService.GetMealsByCategory(category); return(Ok(meal)); }
public IEnumerable <MealListItem> GetMealsByCategory(TypeofMealCategory category) { using (var ctx = new ApplicationDbContext()) { var query = ctx .DailyMeals .Where(e => e.UserId == _userId && e.Category == category) .Select( e => new MealListItem { MealId = e.MealId, MealName = e.MealName, Category = e.Category, CreatedUtc = e.CreatedUtc }); return(query.ToArray()); } }