public void Decrease(int value) { _amount -= value; if (_amount < 0) { _amount = 0; } AmountChanged.SafeInvoke(_amount); }
/// <inheritdoc /> void IMoneyBank.Deduct(Money money) { if (money > CurrentAmount) { CurrentAmount = Money.None; Debug.Fail("Amount deducted was more than the amount allowed"); } else { CurrentAmount -= money; } AmountChanged.Notify(); }
public void Set(string name, int amount) { if (!Items.ContainsKey(name)) { Items.Add(name, new InventoryData() { Item = name }); } Items[name].Amount = amount; if (AmountChanged != null) { AmountChanged.Invoke(this, new InventoryEventArgs(Items[name], amount)); } }
public bool Add(string name, int amount) { if (!Items.ContainsKey(name)) { Items.Add(name, new InventoryData() { Item = name }); } Items[name].Amount += amount; if (AmountChanged != null) { AmountChanged.Invoke(this, new InventoryEventArgs(Items[name], amount)); } // in future check for restrictions like a max amount of inventory space return(true); }
internal void Handle(AmountChanged @event) => _periodOperations.Process(@event);
/// <summary> /// Handles a click event for IncrementBUtton /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnIncrementClicked(object sender, RoutedEventArgs e) { Amount++; AmountChanged?.Invoke(this, new EventArgs()); }
public void СountTurn() { _currentTurnsAmount--; AmountChanged?.Invoke(_currentTurnsAmount); }
public TurnsCounter(int turnsForGame) { _currentTurnsAmount = turnsForGame; AmountChanged?.Invoke(_currentTurnsAmount); }
/// <inheritdoc /> void IMoneyBank.Add(Money money) { CurrentAmount += money; AmountChanged.Notify(); }
public void Increase(int value) { _amount += value; AmountChanged.SafeInvoke(_amount); }
internal void Process(AmountChanged @event) => _allOperations[@event.OperationId.Value].Amount = @event.Amount.Value;
public Task Handle(AmountChanged @event, CancellationToken cancellationToken) { _databaseRepository.UpdateOperation(PeriodId.From(@event.AggregateId), @event.OperationId, @event.Amount); return(Task.CompletedTask); }
protected void OnAmountChange(ValueChangedEventArgs <int> eventArgs) => AmountChanged?.Invoke(this, eventArgs);