public async Task <IActionResult> GetById(int id, CancellationToken cancellationToken = default) { var food = await _foodRepository.FindByIdAsync(id, cancellationToken); if (food == null) { return(BadRequest("No food found")); } return(Ok(_mapper.Map <FoodDTO>(food))); }
public async Task <IHttpActionResult> GetAsync(int foodId) { var food = await _foodRepository.FindByIdAsync(foodId); if (food != null) { return(Ok(food)); } else { return(NotFound()); } }