public IActionResult Create(MealInputModel model) { if (ModelState.IsValid) { var meal = Meal.New(model.Type); _mealRepository.AddMeal(meal); return(RedirectToAction(nameof(Index))); } return(View()); }
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); }
public async Task <ActionResult> TrackMeal(MealInputModel input) => await this.mealsService.TrackMeal(this.currentUser.UserId, input);