public IEnumerable GetNewsOfPageCategory(int CategoryId, int Page) { NewsContext newsContext = new NewsContext(); var dataSet = newsContext.GetNewsOfPage(CategoryId, Page, this.numPage); int NumPage = dataSet.Item2 % this.numPage; if (NumPage > 0) { NumPage = dataSet.Item2 / this.numPage + 1; } Tuple <List <News>, int> dataReturn = Tuple.Create(dataSet.Item1, NumPage); return(JsonConvert.SerializeObject(dataReturn)); }
public ActionResult index() { NewsContext newsBL = new NewsContext(); CategoryContext categoryBL = new CategoryContext(); Tuple <List <News>, int> getDatas = newsBL.GetNewsOfPage(-1, 1, this.pageSize); int NumPage = getDatas.Item2 / this.pageSize; int div = getDatas.Item2 % this.pageSize; if (div > 0) { NumPage++; } ViewData["ListNews"] = Tuple.Create(getDatas.Item1, NumPage); ViewData["ListCategories"] = categoryBL.GetAllCategories(); return(View()); }
public ActionResult GetPageNewsOfCategory(int CategoryId = 13) { NewsContext newsContext = new NewsContext(); CategoryContext categoryContext = new CategoryContext(); var dataSet = newsContext.GetNewsOfPage(CategoryId, 1, this.numPage); int NumPage = dataSet.Item2 % this.numPage; if (NumPage > 0) { NumPage = dataSet.Item2 / this.numPage + 1; } Tuple <List <News>, int, int> dataReturn = Tuple.Create(dataSet.Item1, NumPage, CategoryId); ViewData["ListNews"] = dataReturn; ViewData["ListCategory"] = categoryContext.GetAllCategories(); return(View()); }
public ActionResult Index() { NewsContext newsContext = new NewsContext(); var data = newsContext.GetNewsOfPage(-1, 1, this.numPage); int div = data.Item2 % this.numPage; int numPage = data.Item2 / this.numPage; if (div > 0) { numPage++; } ViewData["ListNews"] = Tuple.Create(data.Item1, numPage); CategoryContext categoryContext = new CategoryContext(); ViewData["ListCategory"] = categoryContext.GetAllCategories(); return(View()); }
public IEnumerable GetNewByPage(int page) { NewsContext newsBL = new NewsContext(); return(JsonConvert.SerializeObject(newsBL.GetNewsOfPage(-1, page, this.pageSize))); }