public IActionResult OnGet() { Instructor = new InstructorWithDictionary(); Instructor.Courses = new Dictionary <string, string>(); Instructor.Courses["1000"] = "New course A"; Instructor.Courses["2000"] = "New course B"; Instructor.Courses["3000"] = "New course C"; return(Page()); }
public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } Instructor = _instructorsInMemoryStore.FirstOrDefault(m => m.ID == id); if (Instructor == null) { return(NotFound()); } //PopulateAssignedCourseData(Instructor); return(Page()); }
public async Task <IActionResult> OnPostAsync(Dictionary <string, string> selectedCourses) { if (!ModelState.IsValid) { return(Page()); } var newInstructor = new InstructorWithDictionary(); newInstructor.Courses = new Dictionary <string, string>(); if (await TryUpdateModelAsync <InstructorWithDictionary>( newInstructor, "Instructor", i => i.FirstMidName, i => i.LastName, i => i.HireDate, i => i.Courses)) { _instructorsInMemoryStore.Add(newInstructor); return(RedirectToPage("./Index")); } return(Page()); }