void AnnounceInsideFactory(CarProduced theEvent) { // TODO: Reduce the Inventory of parts that were just used // TODO: But the whole inventory system needs to be revamped I think :) // Rule: an employee can only build one car a day // so remember who just did it EmployeesWhoHaveProducedACarToday.Add(theEvent.EmployeeName); }
void AnnounceInsideFactory(CarProduced theEvent) { // Reduce the Inventory of parts that were just used to ProduceACar // There is a better way to not repeat the hard-coded Model T parts needed but leave it for now if (theEvent.CarModel == "Model T") { // Parts Needed To Build a Model T // 6 wheels // 1 engine // 2 sets of "bits and pieces // Reduce Parts Stock Inventory by that Amount int currentItemQuantity = 0; // TODO: Rinat, This is atomic and safe right? I think yes because of Factory Agg boundary but...?? // TODO: Negative inventory concerns, check on eventually consistent stuff. if (InventoryOfPartsOnShelf.TryGetValue("wheels", out currentItemQuantity)) { InventoryOfPartsOnShelf["wheels"] = currentItemQuantity - 6; } currentItemQuantity = 0; if (InventoryOfPartsOnShelf.TryGetValue("engine", out currentItemQuantity)) { InventoryOfPartsOnShelf["engine"] = currentItemQuantity - 1; } currentItemQuantity = 0; if (InventoryOfPartsOnShelf.TryGetValue("bits and pieces", out currentItemQuantity)) { InventoryOfPartsOnShelf["bits and pieces"] = currentItemQuantity - 2; } } // Rule: an employee can only produce one car per day // so remember who just did it EmployeesWhoHaveProducedACarToday.Add(theEvent.EmployeeName); }