Exemplo n.º 1
0
        public async Task <IActionResult> GetMeal(int mealId)
        {
            var command = new GetMealQuery(mealId);
            var result  = await _mediatr.Send(command);

            return(result.Failure
          ? Conflict(result)
          : (IActionResult)Ok(result));
        }
Exemplo n.º 2
0
        public async Task <Result <MealDTO> > Handle(GetMealQuery request, CancellationToken cancellationToken)
        {
            if (request.MealId == 0)
            {
                throw new GroceryException("INVALID_MEALID");
            }
            var meal = await _repository.GetMealById(request.MealId);

            if (meal is null)
            {
                throw new GroceryException("INVALID_MEALID");
            }
            return(Result.Ok(_mapper.Map <MealDTO>(meal)));
        }