Ejemplo n.º 1
0
 private void RemoveCurrencyIfShould(SellCurrencyCommand command)
 {
     if (ShouldRemoveCurrency(command))
     {
         command.User.Currencies.Remove(command.UserCurrency);
     }
 }
Ejemplo n.º 2
0
 public User SellCurrency(SellCurrencyCommand command)
 {
     sellCurrencyValidator.ValidateCanSellCurrency(command);
     ChargeCantorEarns(command);
     ChargeUserEarns(command);
     UpdateOrDeleteUserCurrencyAmount(command);
     return(command.User);
 }
Ejemplo n.º 3
0
 public bool ValidateCanSellCurrency(SellCurrencyCommand command)
 {
     transactionValidator.ValidateTransaction(command);
     if (HasUserNotEnoughCurrencyAmount(command))
     {
         throw new SellCurrencyException("User doesn't have enough currency amount");
     }
     return(true);
 }
Ejemplo n.º 4
0
 private bool HasUserNotEnoughCurrencyAmount(SellCurrencyCommand command)
 {
     return(command.UserCurrency.Amount < command.Amount);
 }
Ejemplo n.º 5
0
 private bool ShouldRemoveCurrency(SellCurrencyCommand command)
 {
     return(command.UserCurrency.Amount == 0);
 }
Ejemplo n.º 6
0
 private void EditCurrencyAmount(SellCurrencyCommand command)
 {
     command.UserCurrency.Amount -= command.Amount;
 }
Ejemplo n.º 7
0
 private void UpdateOrDeleteUserCurrencyAmount(SellCurrencyCommand command)
 {
     EditCurrencyAmount(command);
     RemoveCurrencyIfShould(command);
 }
Ejemplo n.º 8
0
 private void ChargeUserEarns(SellCurrencyCommand command)
 {
     command.User.Money += command.UserMoneyEarns;
 }
Ejemplo n.º 9
0
 private void ChargeCantorEarns(SellCurrencyCommand command)
 {
     command.CantorCurrency.Amount += command.Amount;
 }