public void RemoveSpouse(Commands.RemoveSpouseToBenefitsEstimate cmd) { if(this.Spouse.HasValue && this.Spouse.Value.FirstName.Equals(cmd.FirstName, StringComparison.OrdinalIgnoreCase) && this.Spouse.Value.LastName.Equals(cmd.LastName, StringComparison.OrdinalIgnoreCase) ) { var evt = new Events.SpouseRemoved(this.Id, cmd.FirstName, cmd.LastName); this.Emit(evt); //var estimate = this.BroadcastEstimate(); } else { throw new InvalidOperationException("This person is not listed as the employee's spouse."); } }
public void Apply(Events.SpouseRemoved e) { this.Spouse = null; this.MaritalStatus = MaritalStatus.Single; }