/// <summary> /// Initializes a new instance of the <see cref="AgencyAddressAndPhone"/> class. /// </summary> /// <param name="agencyAddress"> /// The agency address. /// </param> protected internal AgencyAddressAndPhone(AgencyAddress agencyAddress) : this() { Check.IsNotNull(agencyAddress, () => AgencyAddress); _agencyAddress = agencyAddress; }
/// <summary> /// Revises the agency address. /// </summary> /// <param name="agencyAddress"> /// The agency address. /// </param> public virtual void ReviseAgencyAddress(AgencyAddress agencyAddress) { Check.IsNotNull(agencyAddress, () => AgencyAddress); DomainRuleEngine.CreateRuleEngine <Agency, AgencyAddress> (Agency, () => ReviseAgencyAddress) .WithContext(agencyAddress) .WithContext(this) .Execute(() => AgencyAddress = agencyAddress); }
/// <summary> /// Adds the address and phone. /// </summary> /// <param name="agencyAddress"> /// The agency address. /// </param> /// <returns> /// An AgencyAddressAndPhone. /// </returns> public virtual AgencyAddressAndPhone AddAddressAndPhone(AgencyAddress agencyAddress) { Check.IsNotNull(agencyAddress, "agencyAddress is required."); AgencyAddressAndPhone addressAndPhone = null; var createdAgencyAddressAndPhone = new AgencyAddressAndPhone(agencyAddress); DomainRuleEngine.CreateRuleEngine(this, "AddAddressAndPhone") .WithContext(createdAgencyAddressAndPhone) .Execute(() => { addressAndPhone = createdAgencyAddressAndPhone; addressAndPhone.Agency = this; _addressesAndPhones.Add(addressAndPhone); NotifyItemAdded(() => AddressesAndPhones, addressAndPhone); }); return(addressAndPhone); }