/// <summary> /// The the location id in data model representation. /// </summary> /// <param name="emailSubscription"> The email subscription. </param> /// <returns> The <see cref="string"/>. </returns> private string GetDataModelLocationId(LoMo.UserServices.DataContract.Location emailSubscription) { Users.Dal.DataModel.LocationType type = (Users.Dal.DataModel.LocationType)Enum.Parse(typeof(Users.Dal.DataModel.LocationType), emailSubscription.LocationType.ToString()); Location location = new Location(emailSubscription.CountryCode, emailSubscription.AdminDistrict, emailSubscription.LocationName, type); return(location.ToString()); }
/// <summary> /// Convert subscription data model into data contract /// </summary> /// <param name="emailSubscription"> /// The email subscription. </param> /// <returns> /// The <see cref="EmailSubscription"/> the data contract representation of the subscription </returns> /// <exception cref="ApplicationException">the data model location id is in wrong format /// </exception> private LoMo.UserServices.DataContract.Location Convert(EmailSubscription emailSubscription) { var dalLocation = Location.Parse(emailSubscription.LocationId); LocationType locationType; if (!Enum.TryParse(dalLocation.Type.ToString(), true, out locationType) || (locationType != LocationType.Postal && locationType != LocationType.National)) { throw new ApplicationException(string.Format("Location Id wrong format. Only postal, national location type are allowed in this phase. Location Id={0}", emailSubscription.LocationId)); } return(new LoMo.UserServices.DataContract.Location { CountryCode = dalLocation.CountryCode, AdminDistrict = dalLocation.AdminDistrict, LocationName = dalLocation.Value, LocationType = locationType }); }