public static async Task AdmitPatients(IEnumerable <Patient> listOfPatients, Dispatcher dispatcher) { foreach (var patient in listOfPatients) { await dispatcher.Dispatch(new AdmitPatient( patient.Id, patient.Name, patient.Age, DateTime.UtcNow, Ward.Get())); Console.WriteLine("Admitting: " + patient.Name); } }
public static async Task TransferPatients(List <Patient> listOfPatients, Dispatcher dispatcher) { for (var i = 0; i < 10; i++) { foreach (var patient in listOfPatients) { var transfer = Random.Next(0, 5) == 0; if (transfer) { await dispatcher.Dispatch(new TransferPatient(patient.Id, Ward.Get())); Console.WriteLine("Transfering: " + patient.Name); } } } }