public ActionResult ViewPlan(string page, string success, string delete_success, string delete_error) { var plans = new List <PlanModel>(); try { if (SessionIsNull()) { return(Redirect("/Home/Login?mustLogin=true&next=/Plan/ViewPlan")); } PlanService ser = new PlanService(); int _page = 1; bool isParsed = int.TryParse(page, out _page); if (!isParsed || _page <= 0) { _page = 1; } plans = ser.ViewPlan(10, _page); int nombre = ser.CountPlan(); ViewBag.pagination = new PageUtility().MakePagination(10, nombre, _page, "/Plan/ViewPlan?page="); ViewData["Plan"] = plans; 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!"; } return(View(plans)); } catch (Exception) { ViewBag.error = "An error has occured!"; return(View(plans)); } }