public ActionResult ViewSubject(string page, string success, string delete_success, string delete_error) { var subjects = new List <SubjectModel>(); try { if (SessionIsNull()) { return(Redirect("/Home/Login?mustLogin=true&next=/Subject/ViewSubject")); } PlanService ser = new PlanService(); int _page = 1; bool isParsed = int.TryParse(page, out _page); if (!isParsed || _page <= 0) { _page = 1; } subjects = ser.ViewSubject(10, _page); int nombre = ser.CountSubject(); ViewBag.pagination = new PageUtility().MakePagination(10, nombre, _page, "/Subject/ViewSubject?page="); ViewData["Subject"] = subjects; SetViewBag(); if (!string.IsNullOrEmpty(success) && success.Equals("true")) { ViewBag.success = "Saving with success!"; } if (!string.IsNullOrEmpty(delete_success) && delete_success.Equals("true")) { ViewBag.success = "Deleting with success!"; } if (!string.IsNullOrEmpty(delete_error) && delete_error.Equals("true")) { ViewBag.error = "An error has occured while deleting!"; } } catch (Exception) { ViewBag.error = "An error has occured"; } return(View(subjects)); }