public IActionResult OnPost(int courseId) { var course = _courseData.Delete(courseId); _courseData.Commit(); if (course == null) { return(RedirectToPage("./NotFound")); } TempData["Message"] = $"{course.Name} deleted"; return(RedirectToPage("./List")); }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } if (Course.Id > 0) { _courseData.Update(Course); TempData["Message"] = "Course updated"; } else { _courseData.Add(Course); TempData["Message"] = "Course created"; } _courseData.Commit(); return(RedirectToPage("./Details", new { courseId = Course.Id })); }