public void UpdatePhoneNumber(EnumValueInfo simplePhoneType, TelephoneNumber number) { SimplifiedPhoneType type = (SimplifiedPhoneType)Enum.Parse(typeof(SimplifiedPhoneType), simplePhoneType.Code); switch (type) { case SimplifiedPhoneType.Home: number.Equipment = TelephoneEquipment.PH; number.Use = TelephoneUse.PRN; break; case SimplifiedPhoneType.Work: number.Equipment = TelephoneEquipment.PH; number.Use = TelephoneUse.WPN; break; case SimplifiedPhoneType.Mobile: number.Equipment = TelephoneEquipment.CP; number.Use = TelephoneUse.PRN; break; case SimplifiedPhoneType.Fax: number.Equipment = TelephoneEquipment.FX; number.Use = TelephoneUse.WPN; break; case SimplifiedPhoneType.Pager: number.Equipment = TelephoneEquipment.BP; number.Use = TelephoneUse.WPN; break; case SimplifiedPhoneType.Unknown: // do nothing break; } }
/// <summary> /// Equivalence comparison which ignores ValidRange /// </summary> /// <param name="that">The TelephoneNumber to compare to</param> /// <returns>True if all fields other than the validity range are the same, False otherwise</returns> public bool IsSameNumber(TelephoneNumber that) { return (that != null) && ((this._countryCode == default(string)) ? (that._countryCode == default(string)) : this._countryCode.Equals(that._countryCode)) && ((this._areaCode == default(string)) ? (that._areaCode == default(string)) : this._areaCode.Equals(that._areaCode)) && ((this._number == default(string)) ? (that._number == default(string)) : this._number.Equals(that._number)) && ((this._extension == default(string)) ? (that._extension == default(string)) : this._extension.Equals(that._extension)) && ((this._use == default(TelephoneUse)) ? (that._use == default(TelephoneUse)) : this._use.Equals(that._use)) && ((this._equipment == default(TelephoneEquipment)) ? (that._equipment == default(TelephoneEquipment)) : this._equipment.Equals(that._equipment)) && true; }
public TelephoneNumber CreateTelephoneNumber(TelephoneDetail telephoneDetail) { if (telephoneDetail == null) return null; TelephoneNumber telephoneNumber = new TelephoneNumber(); telephoneNumber.CountryCode = telephoneDetail.CountryCode; telephoneNumber.AreaCode = telephoneDetail.AreaCode; telephoneNumber.Number = telephoneDetail.Number; telephoneNumber.Extension = telephoneDetail.Extension; telephoneNumber.ValidRange.From = telephoneDetail.ValidRangeFrom; telephoneNumber.ValidRange.Until = telephoneDetail.ValidRangeUntil; SimplifiedPhoneTypeAssembler simplePhoneTypeAssembler = new SimplifiedPhoneTypeAssembler(); simplePhoneTypeAssembler.UpdatePhoneNumber(telephoneDetail.Type, telephoneNumber); return telephoneNumber; }
public TelephoneDetail CreateTelephoneDetail(TelephoneNumber telephoneNumber, IPersistenceContext context) { if (telephoneNumber == null) return null; TelephoneDetail telephoneDetail = new TelephoneDetail(); telephoneDetail.CountryCode = telephoneNumber.CountryCode; telephoneDetail.AreaCode = telephoneNumber.AreaCode; telephoneDetail.Number = telephoneNumber.Number; telephoneDetail.Extension = telephoneNumber.Extension; SimplifiedPhoneTypeAssembler simplePhoneTypeAssembler = new SimplifiedPhoneTypeAssembler(); telephoneDetail.Type = simplePhoneTypeAssembler.GetSimplifiedPhoneType(telephoneNumber); telephoneDetail.ValidRangeFrom = telephoneNumber.ValidRange.From; telephoneDetail.ValidRangeUntil = telephoneNumber.ValidRange.Until; return telephoneDetail; }
public EnumValueInfo GetSimplifiedPhoneType(TelephoneNumber number) { SimplifiedPhoneType t = SimplifiedPhoneType.Unknown; if (number.Use == TelephoneUse.PRN) { if (number.Equipment == TelephoneEquipment.PH) t = SimplifiedPhoneType.Home; else if (number.Equipment == TelephoneEquipment.CP) t = SimplifiedPhoneType.Mobile; } else if (number.Use == TelephoneUse.WPN) { if (number.Equipment == TelephoneEquipment.PH) t = SimplifiedPhoneType.Work; else if (number.Equipment == TelephoneEquipment.BP) t = SimplifiedPhoneType.Pager; else if (number.Equipment == TelephoneEquipment.FX) t = SimplifiedPhoneType.Fax; } return new EnumValueInfo(t.ToString(), t.ToString()); }