/// <summary> /// Retrieve all countries /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <ApiResponse <CountriesResponse> > GetAllCountriesAsync(CancellationToken cancellationToken = default) { var responseModel = new ApiResponse <CountriesResponse>(); var countries = await _countriesRepo.GetAllAsync(); if (!countries.Any()) { return(responseModel); } var countryList = new List <CountryResponse>(); foreach (var country in countries) { countryList.Add(CreateCountryResponse(country)); } responseModel.Data = new CountriesResponse(countryList.ToImmutableList(), countryList.Count); return(responseModel); }
public async Task <IActionResult> GetAllAsync() { var result = await repository.GetAllAsync(); return(Ok(result)); }