public AddressViewModel(Address address) { if (address == null) { throw new ArgumentNullException("address"); } if (address.ContactType == null) { address.ContactType = DefaultManager.Instance.DefaultContactType; } ContactTypeLookup = new ObservableCollection<ContactTypeViewModel>(); foreach (var contactType in DataManager.Instance.GetAllContactTypes()) { ContactTypeLookup.Add(new ContactTypeViewModel(contactType)); } ContactTypeLookup.CollectionChanged += (sender, e) => { if (e.OldItems != null && e.OldItems.Contains(this.ContactType)) { this.ContactType = new ContactTypeViewModel(DefaultManager.Instance.DefaultContactType); } }; this.Model = address; }
/// <summary> /// Deprecated Method for adding a new object to the Addresses EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAddresses(Address address) { base.AddObject("Addresses", address); }
/// <summary> /// Create a new Address object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="contactTypeId">Initial value of the ContactTypeId property.</param> /// <param name="personId">Initial value of the PersonId property.</param> /// <param name="zipCode">Initial value of the ZipCode property.</param> /// <param name="countryName">Initial value of the CountryName property.</param> /// <param name="regionName">Initial value of the RegionName property.</param> /// <param name="cityName">Initial value of the CityName property.</param> /// <param name="streetHouseName">Initial value of the StreetHouseName property.</param> /// <param name="sourceId">Initial value of the SourceId property.</param> public static Address CreateAddress(global::System.Guid id, global::System.Guid contactTypeId, global::System.Guid personId, global::System.String zipCode, global::System.String countryName, global::System.String regionName, global::System.String cityName, global::System.String streetHouseName, global::System.Int32 sourceId) { Address address = new Address(); address.Id = id; address.ContactTypeId = contactTypeId; address.PersonId = personId; address.ZipCode = zipCode; address.CountryName = countryName; address.RegionName = regionName; address.CityName = cityName; address.StreetHouseName = streetHouseName; address.SourceId = sourceId; return address; }