コード例 #1
0
ファイル: CommonBLL.cs プロジェクト: zdolenjashvili/TestApps
        /// <summary>
        /// ქალაქების ცნობარი
        /// </summary>
        /// <param></param>
        /// <returns></returns>
        public async Task <GenericResult <IEnumerable <CityModel> > > GetCities()
        {
            var cities = await CitiesRepository.GetAllAsync();

            if (cities.IsNullOrEmpty())
            {
                return(new GenericResult <IEnumerable <CityModel> >(Result.SuccessInstance(), null));
            }

            var citiesModel = mapper.Map <IEnumerable <Cities>, IEnumerable <CityModel> >(cities);

            return(new GenericResult <IEnumerable <CityModel> >(Result.SuccessInstance(), citiesModel));
        }
コード例 #2
0
        /// <summary>
        /// Retrieve all cities
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <ApiResponse <CityListResponse> > GetAllCitiesAsync(CancellationToken cancellationToken = default)
        {
            var responseModel = new ApiResponse <CityListResponse>();

            var allCities = await _citiesRepo.GetAllAsync();

            if (!allCities.Any())
            {
                return(responseModel);
            }

            var cities = allCities.OrderBy(c => c.Name);

            var cityList = new List <CityResponse>();

            foreach (var city in cities)
            {
                cityList.Add(CreateCityResponse(city));
            }

            responseModel.Data = new CityListResponse(cityList.ToImmutableList(), cityList.Count);

            return(responseModel);
        }
コード例 #3
0
        public async Task <IEnumerable <CityDto> > GetAllCitiesAsync()
        {
            var cities = await _citiesRepository.GetAllAsync();

            return(_mapper.Map <IEnumerable <CityDto> >(cities));
        }
コード例 #4
0
 public async Task <IEnumerable <City> > GetAllCities()
 {
     return(await _citiesRepository.GetAllAsync());
 }