private static void AddConsumption() { IConsumptionHistory consumptionHistory = new ConsumptionHistory(); Console.WriteLine("Patient Id:"); int patientId = -1; while (patientId == -1) { patientId = ReadIntKey(); } consumptionHistory.Patient = PatientService.GetPatient(patientId); Console.WriteLine("Consumption Date (ddMMYYYY format):"); DateTime consumptionDate = new DateTime(); while (consumptionDate == DateTime.MinValue) { string dateToParse = Console.ReadLine().Trim(); DateTime.TryParseExact(dateToParse, "ddMMyyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out consumptionDate); } consumptionHistory.ConsumptionDate = consumptionDate; Console.WriteLine("O2 consumption (in liters):"); int o2LitersConsumption = -1; while (o2LitersConsumption == -1) { o2LitersConsumption = ReadIntKey(); } consumptionHistory.O2LitersConsumption = o2LitersConsumption; List <string> errors = new List <string>(); if (!consumptionHistory.Validate(out errors)) { Console.WriteLine("One or more errors in Add Consumption History:"); foreach (string error in errors) { Console.WriteLine(error); } Console.WriteLine("Consumption History has not been saved, please correct errors and try again. \n"); AddConsumption(); } else { ConsumptionHistoryService.AddConsumptionHistory(consumptionHistory); } }