예제 #1
0
        public void AddItems(string itemID, int amount)
        {
            var seletedItem = _itemTemplateRepository.GetAll().First(x => x.ID == itemID);

            var newItem = new PositionInInventory
            {
                ID = $"{Guid.NewGuid().ToString()}_{seletedItem.ID}", Identyficator = seletedItem.Name, Category = seletedItem.Category, Name = seletedItem.Name, Amount = amount, Effects = seletedItem.Effects
            };

            _positionInInventoryRepository.Add(newItem, _accountManagement.GetLoggedAccount().ID);
        }
예제 #2
0
        public void RemoveItems(string identyficator, int amount)
        {
            var allPositions = _positionInInventoryRepository.GetAll(_accountManagement.GetLoggedAccount().ID);
            var position     = allPositions.First(x => x.Identyficator == identyficator);

            if (position.Amount >= amount)
            {
                position.Amount = amount;
                var removedItem = new PositionInInventory
                {
                    ID = position.ID, Identyficator = position.Name, Category = position.Category, Name = position.Name, Amount = position.Amount, Effects = position.Effects
                };

                _positionInInventoryRepository.Remove(removedItem, _accountManagement.GetLoggedAccount().ID);
            }
        }