public void ApplyEvent(MembershipPointsEarnedEvent simpleEvent) { var point = MembershipPoint.New(simpleEvent.Amount, simpleEvent.PointsType, simpleEvent.EarnedAt); Points.Add(point); Version++; // domain rule. if the new points are in between 200 - 300, and it is a membership type level 1, we upgrade the membership. // if the points above 300 then it would be membership type level 3 if (TotalPoints > 200 && TotalPoints < 300 && Type == MembershipType.Level1) { UpgradeMembership(); } if (TotalPoints > 300) { // convert membership type to lvl 3 if (Type == MembershipType.Level1) { UpgradeMembership(); UpgradeMembership(); } else if (Type == MembershipType.Level2) { UpgradeMembership(); } } }
public void PointsEarned(double points, MembershipPointsType type) { var @event = new MembershipPointsEarnedEvent(Id, points, type, DateTime.UtcNow, Version); ApplyEvent(@event); AppendEvent(@event); }