public async Task <IActionResult> OnPostAsync(long?id, string[] selectedCourses) { if (!ModelState.IsValid) { return(Page()); } var professorToUpdate = await _context.Professor .Include(p => p.CourseAssignment).ThenInclude(p => p.Course) .FirstOrDefaultAsync(s => s.ProfessorId == id);; if (await TryUpdateModelAsync <Professor>( professorToUpdate, "Professor", i => i.FirstName, i => i.LastName )) { UpdateProfessorCourses(_context, selectedCourses, professorToUpdate); await _context.SaveChangesAsync(); return(RedirectToPage("./ProfessorsInfo")); } UpdateProfessorCourses(_context, selectedCourses, professorToUpdate); PopulateAssignedCourseData(_context, professorToUpdate); return(Page()); }
public async Task <IActionResult> OnPostAsync(long sid, string cid) { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Enrollment).State = EntityState.Modified; await _context.SaveChangesAsync(); return(RedirectToPage("./Students", new { id = cid })); }
public async Task <IActionResult> OnPostAsync(string cid) { if (!ModelState.IsValid) { return(Page()); } _context.Announcement.Add(Announcement); await _context.SaveChangesAsync(); return(RedirectToPage("./CoursePage", new { id = cid })); }