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