public async Task <ApplicationStudent> Create(ApplicationStudent application1) { var createdClass = await _context.ApplicationStudents.AddAsync(application1); await _context.SaveChangesAsync(); return(createdClass.Entity); }
/// <summary> /// Show Main menu /// </summary> public void ShowMainMenu() { // Main menu Console.Clear(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("==============================="); Console.WriteLine("1. Manage Students"); Console.WriteLine("2. Manage Lecturers"); Console.WriteLine("3. Exit"); Console.WriteLine("==============================="); // User choose Console.BackgroundColor = ConsoleColor.Red; Console.Write("Please choose: "); string userChoose = String.Empty; userChoose = Console.ReadLine(); Console.ResetColor(); switch (userChoose) { case "1": // Start App Student Management ApplicationStudent appStudentCreator = new ApplicationStudent(); IManagementSystem appStudent = appStudentCreator.MakeApp(); string appStudentResult = appStudent.Start(); if (appStudentResult == "6") { ShowMainMenu(); } break; case "2": // Start App Lecturer Management ApplicationLecturer appLecturerCreator = new ApplicationLecturer(); IManagementSystem appLecturer = appLecturerCreator.MakeApp(); string appLecturerResult = appLecturer.Start(); if (appLecturerResult == "6") { ShowMainMenu(); } break; case "3": // Exit program Environment.Exit(0); break; default: Console.WriteLine("Not correct command. Please input only number (1, 2 or 3)"); ShowMainMenu(); break; } }
public async Task <ApplicationStudent> Update(int id, ApplicationStudent application1) { var applicationToUpdate = await GetById(id); if (applicationToUpdate == null) { return(null); } applicationToUpdate = application1; _context.ApplicationStudents.Update(application1); await _context.SaveChangesAsync(); return(applicationToUpdate); }