Пример #1
0
        public IHttpActionResult GetMealAndFoodsPerDay(FilterDate date)
        {
            IEnumerable <MealViewModel> mealVm;

            CultureInfo provider   = CultureInfo.CurrentCulture;
            var         dateFormat = DateTime.ParseExact(date.filterDate, "MM/dd/yyyy", provider);

            var totalCalories = mealService.SumOfNutrientsPerDay(dateFormat);

            var mealAndFoods = mealService.GetMealAndFoodsPerDay(dateFormat);

            if (totalCalories == null || mealAndFoods == null)
            {
                return(Content(HttpStatusCode.NotFound, "Meals not found."));
            }

            mealVm = mapper.Map <IEnumerable <Meal>, IEnumerable <MealViewModel> >(mealAndFoods);

            return(Content(HttpStatusCode.OK, new { totalCalories, mealVm }));
        }