public void Rechrage(decimal amount, Guid requestId) { CheckRule(new UserBalanceNonnegativeRule(amount)); var transcation = UserTranscation.Create(null, this, requestId, amount); _Transfer(transcation); }
public void TransferTo(User recevier, decimal amount, Guid requestId) { CheckRule(new UserBalanceNonnegativeRule(amount)); var transcation = UserTranscation.Create(this, recevier, requestId, amount); recevier._Transfer(transcation); this._Transfer(UserTranscation.CreateReverse(transcation)); AddDomainEvent(new UserTransferSuccessEvent(this, recevier, amount)); }
private void _Transfer(UserTranscation trancation) { if (trancation.Dircition == TransferDircition.Reduce) { CheckRule(new UserIsufficientBalanceRule(Balance, trancation.Amount)); Balance -= trancation.Amount; } else { Balance += trancation.Amount; } _transcations ??= new List <UserTranscation>(); _transcations.Add(trancation); }