Ejemplo n.º 1
0
        public IActionResult Create(MealInputModel model)
        {
            if (ModelState.IsValid)
            {
                var meal = Meal.New(model.Type);

                _mealRepository.AddMeal(meal);

                return(RedirectToAction(nameof(Index)));
            }

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> TrackMeal(string userId, MealInputModel input)
        {
            var meal = new Meal
            {
                Name     = input.Name,
                Protein  = input.Protein,
                Carbs    = input.Carbs,
                Fat      = input.Fat,
                Calories = input.Calories,
                UserId   = userId
            };

            await this.Save(meal);

            await this.publisher.Publish(new MealTrackedMessage
            {
                MealId   = meal.Id,
                MealName = meal.Name,
                UserId   = userId
            });

            return(Result.Success);
        }
Ejemplo n.º 3
0
 public async Task <ActionResult> TrackMeal(MealInputModel input)
 => await this.mealsService.TrackMeal(this.currentUser.UserId, input);