Пример #1
0
        public async Task <ActionResult> Post([FromBody] MealCreateModel model)
        {
            model.UserId = User.Identity.Name;

            await _mealService.AddMealAsync(model);

            var response = new ResponseModel
            {
                Message = $"The {model.Description} has been added!"
            };

            return(Ok(response));
        }
Пример #2
0
        public async Task <IActionResult> AddMeal([FromBody] MealCreationVM mealCreationVM)
        {
            var userId = new Guid(User.Identity.Name);

            var mealId = await _mealService.AddMealAsync(mealCreationVM, userId);

            if (mealId == Guid.Empty)
            {
                return(NotFound());
            }

            return(Ok(mealId));
        }