public void RemoveDependent(Commands.RemoveDependentToBenefitsEstimate cmd) { if (this.Dependents.Any(x => x.FirstName.Equals(cmd.FirstName, StringComparison.OrdinalIgnoreCase) && x.LastName.Equals(cmd.LastName, StringComparison.OrdinalIgnoreCase))) { var evt = new Events.DependentRemoved(this.Id, cmd.FirstName, cmd.LastName); this.Emit(evt); //var estimate = this.BroadcastEstimate(); } else { throw new InvalidOperationException("This person is not listed as a dependent of the employee."); } }
public void Apply(Events.DependentRemoved e) { this._dependents.RemoveAll(x => x.FirstName.Equals(e.FirstName, StringComparison.OrdinalIgnoreCase) && x.LastName.Equals(e.LastName, StringComparison.OrdinalIgnoreCase)); }