public ActionResult DeleteStudent(string id) // xóa học sinh { if (!user.IsAdmin()) { return(View("Error")); } Model.UpdateLastSeen("Xóa Sinh Viên", Url.Action("DeleteStudent")); int id_student = Convert.ToInt32(id); bool del = Model.DeleteStudent(id_student); if (del) { TempData["status_id"] = true; TempData["status"] = "Xóa Thành Công"; } else { TempData["status_id"] = false; TempData["status"] = "Xóa Thất Bại"; } return(RedirectToAction("StudentManager")); }
public IActionResult DeleteStudent(UserInfo student) { try { int Logged = Convert.ToInt32(HttpContext.Session.GetInt32("Logged")); int User = Convert.ToInt32(HttpContext.Session.GetInt32("User")); if (Logged == 1 && User == 1) { adminDAObj.DeleteStudent(student.UserID); string Success = "Student Deleted successfully"; return(RedirectToAction("StudentList", new { message = Success })); } else { return(RedirectToAction("Login", "Home")); } } catch (Exception ex) { string exMessage = "oops! There is a problem in deleting student."; return(RedirectToAction("Index", "ExeptionHandler", new { Exeption = exMessage })); } }