Review the code and identify following:
public class InventoryManager
private reist<InventoryItem> inventory = new();
private reist<InventoryItem> itemsSold = new();
public event Action<string> ItemSoldOut;
public event Action<string> ItemBecameAvailable;
public float AverageProfit => this.inventory.Sum(i => i.ProfitPerItem) / this.inventory.Count();
public float ProfitLastHour { get; private set; }
public void AddToStock(string itemId, int count)
v var item = ms.inventory.FirstOrDefafault(i => i.Id == itemId);
item.StockCount += count;
if (item.StockCount == count)
this.ItemBecameAvailable(itemId);
public void SellItem(string itemId, int count)
var item = this.inventory.First(i => i.Id == itemId);
item.StockCount -= count;
if (item.StockCount == 0)
this.ItemSoldOut(itemId);
item.Date = DateTime.Now;
this.itemsSold.Add(item);
this.ProfitLastHour = this.itemsSold
.Where(i => i.Date >= DateTime.Now.AddHours(-1))
.Sum(i => i.ProfitPerItem * i.StockCount);
public string Id { get; set; }
public float Price { get; set; }
public float Cost { get; set; }
public int StockCount { get; set; }
public DateTime Date { get; set; }
public float ProfitPerItem => this.Price - this.Cost;