/// <summary> Removes a BillingDetails from the set. /// /// This method checks if the removed is the default element, /// and will throw a BusinessException if there is more than one /// left to chose from. This might actually not be the best way /// to handle this situation. /// /// </summary> public virtual void RemoveBillingDetails(BillingDetails billingDetails) { if (billingDetails == null) { throw new ArgumentException("Can't remove a null BillingDetails."); } if (BillingDetails.Count >= 2) { BillingDetails.Remove(billingDetails); DefaultBillingDetails = BillingDetails.GetEnumerator().Current; } else { throw new BusinessException("Please set new default BillingDetails first"); } }
/// <summary> Adds a BillingDetails to the set. /// /// This method checks if there is only one billing method /// in the set, then makes this the default. /// /// </summary> public virtual void AddBillingDetails(BillingDetails billingDetails) { if (billingDetails == null) { throw new ArgumentException("Can't add a null BillingDetails."); } bool added = BillingDetails.Add(billingDetails); if (!added) { throw new ArgumentException("Duplicates not allowed"); } if (BillingDetails.Count == 1) { DefaultBillingDetails = billingDetails; } }
/// <summary> Removes a BillingDetails from the set. /// /// This method checks if the removed is the default element, /// and will throw a BusinessException if there is more than one /// left to chose from. This might actually not be the best way /// to handle this situation. /// /// </summary> public virtual void RemoveBillingDetails(BillingDetails billingDetails) { if (billingDetails == null) throw new ArgumentException("Can't remove a null BillingDetails."); if (BillingDetails.Count >= 2) { BillingDetails.Remove(billingDetails); DefaultBillingDetails = BillingDetails.GetEnumerator().Current; } else { throw new BusinessException("Please set new default BillingDetails first"); } }
/// <summary> Adds a BillingDetails to the set. /// /// This method checks if there is only one billing method /// in the set, then makes this the default. /// /// </summary> public virtual void AddBillingDetails(BillingDetails billingDetails) { if (billingDetails == null) throw new ArgumentException("Can't add a null BillingDetails."); bool added = BillingDetails.Add(billingDetails); if (!added) throw new ArgumentException("Duplicates not allowed"); if (BillingDetails.Count == 1) { DefaultBillingDetails = billingDetails; } }