//Updates a course public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Course).State = EntityState.Modified; try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(Course.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
//Adds the result. public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } _context.Result.Add(Result); _context.SaveChanges(); return(RedirectToPage("./Index")); }
//Removes a student uses a lamda to check whether the student exists. public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } Student = (from student in _context.Student where student.Id == id select student).FirstOrDefault(); if (Student != null) { _context.Student.Remove(Student); _context.SaveChanges(); } return(RedirectToPage("./Index")); }
//Deletes the result .uses linq query to get the result . public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } Result = (from results in _context.Result where results.Id == id select results).FirstOrDefault(); if (Result != null) { _context.Result.Remove(Result); _context.SaveChanges(); } return(RedirectToPage("./Index")); }
//Removes the course. uses linq query to return the course details public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } Course = (from course in _context.Course where course.Id == id select course).FirstOrDefault(); if (Course != null) { _context.Course.Remove(Course); _context.SaveChanges(); } return(RedirectToPage("./Index")); }