public static void UpdateCourse() { using (MyContext db = new MyContext()) { List <Course> a = db.Courses.OrderBy(x => x.Title).ToList(); Course C = new Course(); C.PrintCourses(a); Console.Write("Please select the ID of the course you want to uddate: "); int id = Convert.ToInt32(Console.ReadLine()); Course C1 = db.Courses.Find(id); Console.WriteLine("Which attribute you want to update?"); Console.WriteLine("1 - Title\n2 - Stream (j for Java C for C#)\n3 - Type (f for full-time p for part-time)\n4 - Start Date of the Course(yyy/mm/dd)\n5 - End Date of the Course(yyy/mm/dd)"); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: Console.WriteLine("Please enter new title"); C1.Title = Console.ReadLine(); break; case 2: Console.WriteLine("Please enter new Stream (j for Java C for C#)"); string stream_input = Console.ReadLine(); if (stream_input == "j") { C1.Stream = true; } else { C1.Stream = false; } break; case 3: Console.WriteLine("Please enter new Type (f for full-time P for part-time)"); string type_input = Console.ReadLine(); if (type_input == "f") { C1.Type = true; } else { C1.Type = false; } break; case 4: Console.WriteLine("Please enter new Start Date(yyyy/mm/dd)"); C1.StartTime = Convert.ToDateTime(Console.ReadLine()); break; case 5: Console.WriteLine("Please enter new End Date(yyyy/mm/dd)"); C1.EndTime = Convert.ToDateTime(Console.ReadLine()); break; } Console.WriteLine("Changes Saved"); db.SaveChanges(); } }