Asp.net web应用程序MVC之Controllers控制器
这里简单介绍一下其中的ReaderController.cs控制器方法
ReaderController.cs控制器
该方法是读者控制器包括了读者分类和读者的增删改查页面返回的数据都在这个控制器中,操作业务都是调用业务层Bll里面的方法实现
public class ReaderController : Controller
{
// GET: Reader
public ActionResult Index()
{
HttpCookie cookie = Request.Cookies["id"];
HttpCookie cookie1 = Request.Cookies["username"];
if (null == cookie || null == cookie1)
{ return RedirectToAction("index", "Login"); }
return View();
}
public ActionResult ReaderCatgory()
{
HttpCookie cookie = Request.Cookies["id"];
HttpCookie cookie1 = Request.Cookies["username"];
if (null == cookie || null == cookie1)
{ return RedirectToAction("index", "Login"); }
return View();
}
[HttpPost]
public string ReaderCatgoryData()
{
int page = Convert.ToInt32(Request["page"].ToString());
int limit = Convert.ToInt32(Request["limit"].ToString());
var start = limit * page - limit + 1;//根据分页的页面去选择数据的开始因素
var end = limit * page;//获得分页的最后因素
return Bll.ReaderCatgory.ListPageTiaoJianJson(page,limit) ;
}
public ActionResult ReaderCatgoryAdd()
{
HttpCookie cookie = Request.Cookies["id"];
HttpCookie cookie1 = Request.Cookies["username"];
if (null == cookie || null == cookie1)
{ return RedirectToAction("index", "Login"); }
return View();
}
[HttpPost]
public JsonResult ReaderCatgorySave()
{
string rname = Request["rname"].ToString();
string rnum = Request["rnum"].ToString();
string rday = Request["rday"].ToString();
string rxnum = Request["rxnum"].ToString();
string idate = Request["idate"].ToString();
int i = Bll.ReaderCatgory.ReaderCatgoryAdd(rname, rnum , rday , rxnum , idate);
return Json(i, JsonRequestBehavior.AllowGet);
}
[HttpPost]
public string ReaderCatgoryDelete()