public void AddResource(ItemQuantity itemQuantity) { if (MissingResourceQuantities.Any(i => i.Id == itemQuantity.Id)) { var alreadyAddedQuantity = MissingResourceQuantities.Single(s => s.Id == itemQuantity.Id); alreadyAddedQuantity.Quantity += itemQuantity.Quantity; } else { MissingResourceQuantities.Add(itemQuantity); } UpdateText(); }
private void UpdateResourceStorage(ItemQuantity item) { var resource = MissingResourceQuantities.SingleOrDefault(s => s.Id == item.Id); if (resource == null) { return; } resource.Quantity -= item.Quantity; if (resource.Quantity < 0) { resource.Quantity = 0; } UpdateText(); }