public GMapAddressDto Create(GMapAddressDto gMapAddressDto)
        {
            GMapAddress gMapAddress = _mapper.Map <GMapAddress>(gMapAddressDto);
            GMapAdministrativeAreaLevel1 gMapAdministrativeAreaLevel1 = _gMapAdministrativeAreaLevel1Service.GetByLabelOrCreate(gMapAddress.gMapAdministrativeAreaLevel1);
            GMapAdministrativeAreaLevel2 gMapAdministrativeAreaLevel2 = _gMapAdministrativeAreaLevel2Service.GetByLabelOrCreate(gMapAddress.gMapAdministrativeAreaLevel2);
            GMapCountry           gMapCountry           = _gMapCountryService.GetByLabelOrCreate(gMapAddress.gMapCountry);
            GMapLocality          gMapLocality          = _gMapLocalityService.GetByLabelOrCreate(gMapAddress.gMapLocality);
            GMapNeighborhood      gMapNeighborhood      = _gMapNeighborhoodService.GetByLabelOrCreate(gMapAddress.gMapNeighborhood);
            GMapPostalCode        gMapPostalCode        = _gMapPostalCodeService.GetByLabelOrCreate(gMapAddress.gMapPostalCode);
            GMapRoute             gMapRoute             = _gMapRouteService.GetByLabelOrCreate(gMapAddress.gMapRoute);
            GMapStreetNumber      gMapStreetNumber      = _gMapStreetNumberService.GetByLabelOrCreate(gMapAddress.gMapStreetNumber);
            GMapSublocalityLevel1 gMapSublocalityLevel1 = _gMapSublocalityLevel1Service.GetByLabelOrCreate(gMapAddress.gMapSublocalityLevel1);
            GMapSublocalityLevel2 gMapSublocalityLevel2 = _gMapSublocalityLevel2Service.GetByLabelOrCreate(gMapAddress.gMapSublocalityLevel2);

            gMapAddress.idGMapAdministrativeAreaLevel1 = gMapAdministrativeAreaLevel1.Id;
            gMapAddress.idGMapAdministrativeAreaLevel2 = gMapAdministrativeAreaLevel2.Id;
            gMapAddress.idGMapCountry           = gMapCountry.Id;
            gMapAddress.idGMapLocality          = gMapLocality.Id;
            gMapAddress.idGMapNeighborhood      = gMapNeighborhood.Id;
            gMapAddress.idGMapPostalCode        = gMapPostalCode.Id;
            gMapAddress.idGMapRoute             = gMapRoute.Id;
            gMapAddress.idGMapStreetNumber      = gMapStreetNumber.Id;
            gMapAddress.idGMapSublocalityLevel1 = gMapSublocalityLevel1.Id;
            gMapAddress.idGMapSublocalityLevel2 = gMapSublocalityLevel2.Id;

            List <GMapTypeDto> gMapTypes = _gMapTypeService.GetByKeywordOrCreate(_mapper.Map <List <GMapType> >(gMapAddressDto.GMapTypes), EnumLanguage.FR);


            //Recherche si adresse existe deja
            var gMapAddressDuplicate = _gMapAddressRepository.GetByGMapAddress(gMapAddress);

            if (gMapAddressDuplicate == null)
            {
                gMapAddress    = _gMapAddressRepository.Create(gMapAddress);
                gMapAddressDto = _mapper.Map <GMapAddressDto>(gMapAddress);

                //creation du GMapAddressType
                List <GMapAddressType> gMapAddressTypes = _gMapAddressTypeService.Create(gMapAddress.Id, gMapTypes);
                gMapAddressDto.GMapTypes = gMapTypes; // _mapper.Map<List<SelectDto>>(gMapTypes);
            }
            else
            {
                gMapAddressDto           = _mapper.Map <GMapAddressDto>(gMapAddressDuplicate);
                gMapAddressDto.GMapTypes = gMapTypes; // _mapper.Map<List<SelectDto>>(_gMapAddressTypeService.GetByIdGMapAddress(gMapAddressDuplicate.Id));
            }

            return(gMapAddressDto);
        }
Exemple #2
0
 public GMapCountry GetByLabelOrCreate(GMapCountry gMapCountry)
 {
     return(_gMapCountryRepository.GetByLabelOrCreate(gMapCountry));
 }