public static WorkingDay CreateNewDay() { Console.Clear(); WorkingDay Day = new WorkingDay(); Console.WriteLine("Enter name of doctor"); Day.Name = Console.ReadLine(); Console.WriteLine("Enter speciality"); Day.Speciality = Console.ReadLine(); Console.WriteLine("Enter date of day like 01.02.2000"); Day.Date = Console.ReadLine(); Console.WriteLine("Enter patients count"); Day.PatientsCount = Console.ReadLine(); Console.WriteLine("Enter time of starting work"); Day.StartHour = Console.ReadLine(); return(Day); }
public static void ChangeData(List <WorkingDay> Days) { Console.WriteLine("Enter date of day that`s you want to change"); var s = Console.ReadLine(); WorkingDay day = Days.Find(x => x.Date == s); if (day != null) { Console.WriteLine("Enter value of day that`s you want to change \n1)Name\n2)Speciality\n3)Date like 01.02.2000\n4)Patients count\n5)Start Hour"); char a = Console.ReadKey().KeyChar; Console.WriteLine("Enter new value"); switch (a) { case '1': day.Name = Console.ReadLine(); break; case '2': day.Speciality = Console.ReadLine(); break; case '3': day.Date = Console.ReadLine(); break; case '4': day.PatientsCount = Console.ReadLine(); break; case '5': day.StartHour = Console.ReadLine(); break; } } }
static void Main(string[] args) { while (true) { Console.WriteLine("_____________________________________________________"); Console.WriteLine(" Hot key │ Function |"); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" A │ Add new day |"); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" C │ Change day |"); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" D │ Delete day |"); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" T │ Show all days |"); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" H │ Average number of patients | "); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" M │ Number of days with max load | "); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" P │ Days with wrong time | "); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" Space │ Clear console | "); Console.WriteLine("_____________________________________________________"); Console.WriteLine(" Esc │ Exit program | "); Console.WriteLine("_____________________________________________________"); if (!File.Exists(FileName)) { File.Create(FileName).Close(); } var Days = JsonConvert.DeserializeObject <List <WorkingDay> >(File.ReadAllText(FilePath)); WorkingDay Wd = new WorkingDay(); switch (Console.ReadKey().Key) { case ConsoleKey.A: if (Days == null) { Days = new List <WorkingDay>(); Days.Add(CreateNewDay()); } else { Days.Add(CreateNewDay()); } break; case ConsoleKey.C: ChangeData(Days); break; case ConsoleKey.D: DelteDay(Days); break; case ConsoleKey.T: ShowAll(Days); break; case ConsoleKey.Escape: Environment.Exit(0); break; case ConsoleKey.H: Wd.AveragePatients(Days); break; case ConsoleKey.P: Wd.HoursOnProject(Days); break; case ConsoleKey.M: Wd.MaxLoad(Days); break; case ConsoleKey.Spacebar: Console.Clear(); break; } string serialize = JsonConvert.SerializeObject(Days, Formatting.Indented); if (serialize.Count() > 1) { if (!File.Exists(FileName)) { File.Create(FileName).Close(); } File.WriteAllText(FilePath, serialize, Encoding.UTF8); } } }