예제 #1
0
        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();
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
 internal void Handle(AmountChanged @event) => _periodOperations.Process(@event);
예제 #6
0
 /// <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());
 }
예제 #7
0
 public void СountTurn()
 {
     _currentTurnsAmount--;
     AmountChanged?.Invoke(_currentTurnsAmount);
 }
예제 #8
0
 public TurnsCounter(int turnsForGame)
 {
     _currentTurnsAmount = turnsForGame;
     AmountChanged?.Invoke(_currentTurnsAmount);
 }
 /// <inheritdoc />
 void IMoneyBank.Add(Money money)
 {
     CurrentAmount += money;
     AmountChanged.Notify();
 }
예제 #10
0
 public void Increase(int value)
 {
     _amount += value;
     AmountChanged.SafeInvoke(_amount);
 }
예제 #11
0
 internal void Process(AmountChanged @event) => _allOperations[@event.OperationId.Value].Amount             = @event.Amount.Value;
예제 #12
0
 public Task Handle(AmountChanged @event, CancellationToken cancellationToken)
 {
     _databaseRepository.UpdateOperation(PeriodId.From(@event.AggregateId), @event.OperationId, @event.Amount);
     return(Task.CompletedTask);
 }
예제 #13
0
 protected void OnAmountChange(ValueChangedEventArgs <int> eventArgs) => AmountChanged?.Invoke(this, eventArgs);