public async Task <BaseResponse <Food> > Handle(GetListFoodQuery request, CancellationToken cancellationToken) { var response = new BaseResponse <Food> () { ReponseName = nameof(GetListFoodQuery), Content = new List <Food> () { } }; var entity = await _foodRepository.GetAllAsync(); entity = _mapper.Map <List <Food> > (entity); if (entity == null) { response.Status = ResponseType.Error; response.Message = $"{nameof(Food)} not found."; response.Content = null; } else { response.Status = ResponseType.Success; response.Message = $"{nameof(Food)} get successfully."; response.Content.AddRange(entity); } return(response); }
/// <inheritdoc /> public async Task <IEnumerable <FoodDto> > GetAllAsync() { var entities = await _repo.GetAllAsync(); var dtos = _mapper.Map <IEnumerable <FoodDto> >(entities); return(dtos); }
public async Task <ActionResult <IEnumerable <FoodItemDto> > > GetAllAsync() { var foodItems = (await _foodRepository .GetAllAsync()) .Select(record => record .ConvertToDto()); return(Ok(foodItems)); }
// GET: Foods public async Task <IActionResult> Index() { var dbResult = await _foodRepository.GetAllAsync(); if (!dbResult.Success || dbResult.Data == null) { return(NotFound()); } return(View(dbResult.Data)); }
public async Task <IEnumerable <Food> > GetAsync() { return(await _foodRepository.GetAllAsync()); }