public static void ChangeData(List <WorkingDay> Days) { Console.WriteLine("Enter date of day that`s you want to change"); var s = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", null); 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)Adress\n3)Date like 01.02.2000\n4)Book Out\n5)Book In"); char a = Console.ReadKey().KeyChar; Console.WriteLine("Enter new value"); switch (a) { case '1': day.Name = Console.ReadLine(); break; case '2': day.Address = Console.ReadLine(); break; case '3': day.Date = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", null); break; case '4': day.BookOutCount = Convert.ToInt16(Console.ReadLine()); break; case '5': day.BookInCount = Convert.ToInt16(Console.ReadLine()); break; } } }
static void Main(string[] args) { Console.WriteLine("Enter path to file 'FileName.json' if file not exist it will created"); string path = Console.ReadLine(); List <WorkingDay> Days = ReadFile(path); while (true) { Console.Clear(); Show(Days); var k = Console.ReadKey().Key; Console.Clear(); WorkingDay dd = new WorkingDay(); switch (k) { case ConsoleKey.A: if (Days == null) { Days = new List <WorkingDay>(); Days.Add(CreateNewDay()); } else { Days.Add(CreateNewDay()); } break; case ConsoleKey.D: DelteDay(Days); break; case ConsoleKey.C: ChangeData(Days); break; case ConsoleKey.Enter: return; break; case ConsoleKey.M: dd.MidlleBookMove(Days); break; case ConsoleKey.B: dd.CountOfBookMore(Days); Console.ReadKey(); break; case ConsoleKey.P: dd.PairReturned(Days); break; } SaveFile(path, Days); } }
public static WorkingDay CreateNewDay() { Console.Clear(); WorkingDay Day = new WorkingDay(); Console.WriteLine("Enter Name of library"); Day.Name = Console.ReadLine(); Console.WriteLine("Enter adress of library"); Day.Address = Console.ReadLine(); Console.WriteLine("Enter date of day like 01.02.2000"); Day.Date = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", null); Console.WriteLine("Enter Book in count"); Day.BookInCount = Convert.ToInt16(Console.ReadLine()); Console.WriteLine("Enter Book out count"); Day.BookOutCount = Convert.ToInt16(Console.ReadLine()); return(Day); }