Exemple #1
0
      private GetSubscriberInfoResult _getCustomer(A.GetContactRelatedInfoResponse res) {
         if (res == null || res.person == null || res.person.personDetails == null) return null;
         var details = res.person.personDetails;

         var opco = _getOperator(details.IMTSI);
         if (opco == null) return null;

         var driver = new DriverInfo {
            DriverId = BplIdentity.Get(details.IMTSI),
            DriverSsn = details.personID,
            Operator = opco,
            Gender = _getGender(details.gender),
            Type = DriverTypes.Subscriber
         };

         var subscriber = new GetSubscriberInfoResult {
            DriverInfo = driver
         };

         var lang = opco.DefaultLanguage;
         if (lang.NotEmpty()) {
            driver.DefaultLocale = new Locale(lang);
            driver.Name = _getMultiString("{0} {1}".Substitute(details.firstName, details.lastName), lang);
         }
         
         if (details.birthdateSpecified) {
            driver.BirthDate = (Date)details.birthdate;
         }

         if (details.primaryAddress != null) {
            var addr = _getAddress(details.primaryAddress, opco, ContactTypes.HomeAddress);
            if (addr != null) {
               driver.Contacts.Add(addr);
            }
         }

         if (details.additionalAddresses != null) {
            foreach (var a in details.additionalAddresses) {
               var addr = _getAddress(a, opco, ContactTypes.OtherAddress);
               if (addr != null) {
                  driver.Contacts.Add(addr);
               }
            }
         }

         if (details.email != null) {
            driver.Contacts.Add(new Contact { Type = ContactTypes.Email, Value = details.email });
         }

         if (details.contactMethodInfo != null) {
            driver.Contacts.AddRange(details.contactMethodInfo.Select(c => _getContactInfo(c, opco)));
         }

         if (details.invoiceIndicator != null) {
            driver.Type = (bool)details.invoiceIndicator ? DriverTypes.Payer : DriverTypes.Subscriber;
         }

         if (res.vehicleList != null) {
            for (int i = 0; i < res.vehicleList.Length; i++) {
               subscriber.DriverVehicles.Add(new VehicleInfo {
                  LicensePlate = res.vehicleList[i].licensePlate,
                  VehicleId = BplIdentity.Get(res.vehicleList[i].vehicleID)
               });
            }
         }

         return subscriber;
      }
Exemple #2
0
 private static Contact _getAddress(A.Address address, Operator opco, ContactType type) {
    if (address == null || opco == null) return null;
    var addr = new AddressStruct {
       CityName = address.city,
       CountryCode = opco.CountryCode,
       HouseNumber = address.streetNumber,
       PostalCode = address.postcode,
       StreetName = address.streetName,
       ZipCode = address.postcode
    };
    return new Contact { Type = type, Value = _formatPrimaryAddress(addr) };
 }
Exemple #3
0
 private PhoneStruct _getPhone(A.PersonDetails personDetails) {
    var cm = personDetails.contactMethodInfo;
    if (cm != null && cm.Length > 0) {
       var info = cm.FirstOrDefault(ci => ci.contactMethodType.EqualsIgnoreCase("PH"));
       if (info != null) {
          return PhoneStruct.Parse(info.contactMethodValue);
       }
    }
    return null;
 }
Exemple #4
0
 private Contact _getContactInfo(A.ContactMethodInfo c, Operator opco) {
    ContactType type = null;
    if (c.contactMethodType == "PH") type = ContactTypes.Phone;
    else if (c.contactMethodType == "EM") type = ContactTypes.Email;
    else if (c.contactMethodType == "MO" || c.contactMethodType == "M") type = ContactTypes.MobilePhone;
    else {
       Log.Warn("Unknown Contact type {0}", c.contactMethodType);
       type = ContactTypes.OtherAddress;
    }
    return new Contact { Type = type, Value = c.contactMethodValue };
 }