コード例 #1
0
        public CommunityApiModel MapGet(Community community, LocationElemensDto locationElementsDto, List <Section> sections)
        {
            BasicInfoApiModel        basicInfoApiModel         = new BasicInfoApiModel();
            AssociationApiModel      associationApiModel       = new AssociationApiModel();
            LocationApiModel         locationApiModel          = new LocationApiModel();
            SelectedLocationApiModel selectedLocationViewModel = new SelectedLocationApiModel();

            _mapper.Map(community, basicInfoApiModel);
            _mapper.Map(community.Association, associationApiModel);
            _mapper.Map(community.Location, locationApiModel);

            selectedLocationViewModel.Countries = Map(locationElementsDto.Countries);
            selectedLocationViewModel.States    = Map(locationElementsDto.States);
            selectedLocationViewModel.Cities    = Map(locationElementsDto.Cities);
            selectedLocationViewModel.Areas     = Map(locationElementsDto.Areas);
            selectedLocationViewModel.SubAreas  = Map(locationElementsDto.SubAreas);

            JObject jObject = new JObject();

            Map(jObject, sections);
            return(new CommunityApiModel()
            {
                BasicInfo = basicInfoApiModel,
                Association = associationApiModel,
                SelectedLocation = selectedLocationViewModel,
                Sections = jObject.ToObject <Dictionary <string, object> >()
            });
        }
コード例 #2
0
        public ActionResult Get(Guid id)
        {
            try
            {
                var serviceResponse = _communityService.GetCombinedById(id);
                if (serviceResponse.IsError())
                {
                    return(new ObjectNotFoundResult(serviceResponse));
                }

                Community community = serviceResponse.GetData <Community>();
                Location  location  = community.Location;

                ApiResponse apiResponse = this._locationService
                                          .GetChildLocations(location.CountryId.Value,
                                                             location.StateId.Value,
                                                             location.CityId.Value,
                                                             community.AreaId);

                LocationElemensDto locationElementsDto = apiResponse.GetData <LocationElemensDto>();

                apiResponse = _sectionService.GetByComunityId(id);
                var sections = apiResponse.GetData <List <Section> >();
                CommunityApiModel communityApiModel = _communityMapper.MapGet(community, locationElementsDto, sections);

                return(new ObjectFoundResult(new ApiResponse(communityApiModel)));
            }
            catch (Exception ex)
            {
                return(new UnknownErrorResult(ex, base._errorEnabled));
            }
        }
コード例 #3
0
        public ApiResponse GetChildLocations(Guid countryId, Guid stateId, Guid cityId, Guid areaId)
        {
            var countriesTask = this.GetCountriesAsync();
            var statesTask    = this.GetStatesByCountryIdAsync(countryId);
            var citiesTask    = this.GetCitiesByStateIdAsync(stateId);
            var areasTask     = this.GetAreasByCityIdAsync(cityId);
            var subareaTask   = this.GetSubAreasByAreaIdAsync(areaId);

            Task.WaitAll(countriesTask, statesTask, citiesTask, areasTask, subareaTask);

            LocationElemensDto locationDto = new LocationElemensDto();

            locationDto.Countries = countriesTask.Result;
            locationDto.States    = statesTask.Result;
            locationDto.Cities    = citiesTask.Result;
            locationDto.Areas     = areasTask.Result;
            locationDto.SubAreas  = subareaTask.Result;

            return(new ApiResponse(locationDto));
        }