public ActionResult ProductCategory(int?page, string ProductCategoryID) { if (string.IsNullOrEmpty(ProductCategoryID)) { return(RedirectToAction("Error", "Error")); } int pageSize = 18; int pageNumber = page ?? 1; ViewBag.ProductCategories = db.ProductCategories.ToList(); ViewBag.Categories = db.Categories.Take(5).ToList(); ProductCategory pC = db.ProductCategories.SingleOrDefault(p => p.ProductCategoryID.ToString() == ProductCategoryID); if (pC == null) { return(RedirectToAction("Error", "Error")); } PagedList.IPagedList <Product> lstProduct = db.Products.Where(p => p.ProductCategoryID.ToString() == ProductCategoryID).OrderBy(p => p.Price).ToPagedList(pageNumber, pageSize); if (lstProduct.Count() == 0) { return(RedirectToAction("EmptyProductCategory")); } ViewBag.ProductCategoryName = pC.Name; return(View(lstProduct)); }
public ActionResult AdminList(int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <Admin> adminPagedList = entity.Admins.OrderBy(p => p.AId).ToPagedList(page, 10); return(View(adminPagedList)); }
//查看班级页视图 public ActionResult CheckGrade(string id, int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <Grade> grade = entity.Grades.OrderBy(p => p.GId).OrderBy(c => c.ACId).ToPagedList(page, 10); return(View(grade)); }
//查看学生页视图 public ActionResult CheckStudent(string id, int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <Student> student = entity.Students.OrderBy(p => p.SId).ToPagedList(page, 10); return(View(student)); }
//查看课程页视图 public ActionResult CheckCourse(string id, int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <Course> course = entity.Courses.OrderBy(p => p.CId).ToPagedList(page, 10); return(View(course)); }
//查看学院页视图 public ActionResult CheckACademy(string id, int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <ACademy> academy = entity.ACademys.OrderBy(p => p.ACId).ToPagedList(page, 10); return(View(academy)); }
//查看教师页视图 public ActionResult CheckTeacher(string id, int page = 1) { ViewBag.AId = Session["AId"]; string adminid = Convert.ToString(Session["AId"]); ViewBag.APower = entity.Admins.Where(p => p.AId == adminid).First().APower; ViewBag.AName = entity.Admins.Where(p => p.AId == adminid).First().AName; PagedList.IPagedList <Teacher> teacher = entity.Teachers.OrderBy(p => p.TId).ToPagedList(page, 10); return(View(teacher)); }
public ActionResult TimKiemCode(int?page, string searchText) { string maND = Request.Cookies["MaND"].Value.ToString(); if (maND == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadGateway)); } int id = Int32.Parse(maND.ToString()); PagedList.IPagedList <CodeTable> codeTables = db.CodeTables.Where(t => t.TenCode.Contains(searchText) || t.MaCode.ToString().Contains(searchText)).OrderBy(t => t.NgayDang).ToPagedList(page ?? 1, PAGE_SIZE); return(View("dsCode", codeTables)); }
public void GetMessagesDataForRole_RoleBTMPage0SearchStringNotNull_HttpNotFound() { //Arrange MessageController messageController = new MessageController(mock.Object); PagedList.IPagedList <IMessage> onePageOfMessages = mock.Object.Messages.OrderByDescending(m => m.TimeStamp).ToList().ToPagedList(1, 5); //Act HttpNotFoundResult result = messageController.GetMessagesDataForRole(3, "BTM", "BTMView", "B", 0) as HttpNotFoundResult; //Assert Assert.IsInstanceOf(typeof(HttpNotFoundResult), result); Assert.AreEqual("Wrong Page", ((HttpNotFoundResult)result).StatusDescription); Assert.AreEqual(404, ((HttpNotFoundResult)result).StatusCode); }
public ShopViewModel(int?crntPage, int?pageSize) { try { crntPage = (crntPage ?? 1); pageSize = (pageSize ?? 9); SaleOffItems = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.OriginalPrice > u.Price).OrderBy(u => u.CreationDate).Take(9).ToList(); LatestItems = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true).OrderByDescending(u => u.CreationDate).Take(9).ToList(); CategoryList = db.Categories.Include(c => c.SubCategories).ToList(); MaxCommodityPrice = (int)db.Commodities.Max(c => c.Price); var results = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Include(u => u.PriceUnit).Where(u => u.Available == true && u.Publish == true).OrderByDescending(u => u.CreationDate); Items = results.ToPagedList((int)crntPage, (int)pageSize); } catch { } }
public ActionResult Index(int page = 0, int AllCpage = 1, int SeleCpage = 1) { string SId = Convert.ToString(Session["SId"]); //个人信息 Student student = entity.Students.Where(p => p.SId == SId).FirstOrDefault(); //所有课程 PagedList.IPagedList <Course> course = entity.Courses.OrderBy(c => c.CId).ToPagedList(AllCpage, 10); //所选的课 PagedList.IPagedList <SeleCourse> selecourse = entity.SeleCourses.Where(c => c.SId == SId).OrderBy(p => p.CId).ToPagedList(SeleCpage, 10); var tupleList = new Tuple <Student, PagedList.IPagedList <Course>, PagedList.IPagedList <SeleCourse>, int>(student, course, selecourse, page); return(PartialView(tupleList)); }
public void GetMessagesDataForRole_RolePUPage1SearchStringEmpty_ValidViewAllMessages() { //Arrange MessageController messageController = new MessageController(mock.Object); PagedList.IPagedList <IMessage> onePageOfMessages = mock.Object.Messages.OrderByDescending(m => m.TimeStamp).ToList().ToPagedList(1, 4); //Act ViewResult result = messageController.GetMessagesDataForRole(4, "PU", "PUView", "") as ViewResult; //Assert Assert.AreEqual(typeof(ViewResult), result.GetType()); Assert.AreEqual(onePageOfMessages, result.ViewBag.onePageOfMessages); Assert.AreEqual("PUView", result.ViewBag.actionNameForPagination); Assert.AreEqual(false, result.ViewBag.ShowLinks); Assert.AreEqual(4, result.ViewBag.TabID); Assert.AreEqual("PU", result.ViewBag.Role); Assert.AreEqual(8, ((PagedList.IPagedList <IMessage>)result.ViewBag.OnePageOfMessages).TotalItemCount); }
public ActionResult Index(int Cpage = 1, int Spage = 1, int show = 1) { int Sp = Spage; string TId = Convert.ToString(Session["TId"]); Teacher teacher = entity.Teachers.Where(p => p.TId == TId).FirstOrDefault(); PagedList.IPagedList <Course> coursePagedList = entity.Courses.Where(p => p.TId == TId).OrderBy(x => x.CId).ToPagedList(Cpage, 5); List <PagedList.IPagedList <SeleCourse> > LS = new List <PagedList.IPagedList <SeleCourse> >(); foreach (var item in coursePagedList) { PagedList.IPagedList <SeleCourse> selecoursePagedList = entity.SeleCourses.Where(p => p.CId == item.CId).OrderBy(p => p.SId).ToPagedList(Spage, 5); LS.Add(selecoursePagedList); } var tupleList = new Tuple <PagedList.IPagedList <Course>, Teacher, List <PagedList.IPagedList <SeleCourse> >, int>(coursePagedList, teacher, LS, show); return(PartialView(tupleList)); }
public ActionResult Coupon(int?p, string df, string dt, string key, int hid = 0) { int pageSize = 30; int pageNumber = Shared.GetPageNumber(p); PagedList.IPagedList <UserinfoList> list = null; using (DatabaseContext context = new DatabaseContext()) { try { ViewBag.DateFrom = df; ViewBag.DateTo = dt; ViewBag.HotspotId = hid; ViewBag.KeyWord = key; string CouponCancel = System.Configuration.ConfigurationManager.AppSettings["CouponCancel"].ToString(); DateTime?dateFrom = null; DateTime?dateTo = null; if (!string.IsNullOrEmpty(df)) { dateFrom = Convert.ToDateTime(df, Shared.CultureInfoTh); } if (!string.IsNullOrEmpty(dt)) { dateTo = Convert.ToDateTime(dt, Shared.CultureInfoTh).AddDays(1); } var model = (from b in context.UserBillinfo join i in context.Userinfo on b.username equals i.username join rg in context.RadUsergroup on b.username equals rg.username join h in context.Hotspot on b.hotspot_id equals h.id join pl in context.Plan on b.planName equals pl.planName into pl_leftjoin from pl in pl_leftjoin.DefaultIfEmpty() where rg.groupname != CouponCancel orderby b.creationdate descending select new UserinfoList { id = b.id, username = b.username, firstname = i.firstname, lastname = i.lastname, id_card = i.id_card, mobilephone = i.mobilephone, email = i.email, ref1 = i.ref1, ref2 = i.ref2, expiredate = (i.expiredate.HasValue) ? i.expiredate : null, packagename = b.planName, groupname = rg.groupname, packageprice = string.IsNullOrEmpty(pl.planCost) ? "0" : pl.planCost, creationdate = b.creationdate, hotspot_id = b.hotspot_id, hotspot_name = h.name }) .WhereIf(hid > 0, w => w.hotspot_id == hid) .WhereIf(!string.IsNullOrEmpty(df), w => w.creationdate >= dateFrom) .WhereIf(!string.IsNullOrEmpty(dt), w => w.creationdate < dateTo) .WhereIf(!string.IsNullOrEmpty(key), w => w.firstname.Contains(key.Trim()) || w.lastname.Contains(key.Trim()) || w.id_card.Contains(key.Trim()) || w.mobilephone.Contains(key.Trim()) || w.email.Contains(key.Trim()) || w.ref1.Contains(key.Trim()) || w.ref2.Contains(key.Trim()) || w.username.Contains(key.Trim()) || w.hotspot_name.Contains(key.Trim()) ); list = model.ToPagedList(pageNumber, pageSize); if ((pageNumber > list.PageCount) && (list.PageCount > 0)) { list = model.ToPagedList(list.PageCount, pageSize); } ViewData["Hotspot"] = context.Hotspot.ToList <Hotspot>(); } catch (Exception ex) { string msgError = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; ViewBag.Error = msgError; LogManager.Error("Report.Coupon Error -> " + msgError); } } return(View(list)); }
public ShopViewModel(int?CategoryId, int?subCatId, int?minPrice, int?maxPrice, int?sortField, int?crntPage, int?pageSize, string searchText) { try { SaleOffItems = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.SubCategory.CategoryId == CategoryId && u.OriginalPrice > u.Price).OrderBy(u => u.CreationDate).Take(9).ToList(); LatestItems = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.SubCategory.CategoryId == CategoryId).OrderByDescending(u => u.CreationDate).Take(9).ToList(); CategoryList = db.Categories.Include(c => c.SubCategories).ToList(); MaxCommodityPrice = (int)db.Commodities.Max(c => c.Price); //------------------------------------------------------------ minPrice = (minPrice ?? 1); maxPrice = (maxPrice ?? 999999); sortField = (sortField ?? 1); crntPage = (crntPage ?? 1); pageSize = (pageSize ?? 9); searchText = (searchText ?? ""); //Items = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Include(u => u.PriceUnit).Where(u => u.Available == true && u.Publish == true && u.Title.ToLower().Contains(term)).OrderByDescending(u => u.CreationDate).ToList(); var results = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.Price >= minPrice && u.Price <= maxPrice && u.Title.ToLower().Contains(searchText)); if (CategoryId != null) { SelectedCategory = db.Categories.Where(c => c.CategoryId == CategoryId).FirstOrDefault(); results = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.Price >= minPrice && u.Price <= maxPrice && u.SubCategory.CategoryId == CategoryId && u.Title.ToLower().Contains(searchText)); } if (subCatId != null) { SelectedSubCategory = db.SubCategories.Where(s => s.SubCategoryId == subCatId).FirstOrDefault(); results = db.Commodities.Include(u => u.AspNetUser).Include(u => u.PriceUnit).Include(u => u.SubCategory).Include(u => u.CommodityImages).Include(u => u.CommodityRatings).Where(u => u.Available == true && u.Publish == true && u.Price >= minPrice && u.Price <= maxPrice && u.SubCategory.SubCategoryId == subCatId && u.Title.ToLower().Contains(searchText)); } switch (sortField) { case 1: { // وصل حديثاً results = results.OrderByDescending(c => c.CreationDate); break; } case 2: { // الأعلى تقييماً results = results.OrderByDescending(c => c.Rating); break; } case 3: { // السعر: من الأقل للأكثر results = results.OrderBy(c => c.Price); break; } case 4: { // السعر: من الأكثر للأقل results = results.OrderByDescending(c => c.Price); break; } } // switch Items = results.ToPagedList((int)crntPage, (int)pageSize); } catch (Exception ex) { } }
public ActionResult Products(int page = 1) { PagedList.IPagedList <tblProduct> productModel = db.tblProduct.OrderByDescending(x => x.Id).ToPagedList <tblProduct>(page, 10); return(View(productModel)); }
public ActionResult Users(int page = 1) { PagedList.IPagedList <tblUsers> userModel = db.tblUsers.OrderByDescending(x => x.Id).ToPagedList <tblUsers>(page, 10); return(View(userModel)); }
public ActionResult PendingOrders(int page = 1) { PagedList.IPagedList <tblOrder> orderModel = db.tblOrder.Where(x => x.isShipped == false).OrderByDescending(x => x.Id).ToPagedList <tblOrder>(page, 10); return(View(orderModel)); }
public ActionResult Orders(int page = 1) { PagedList.IPagedList <tblOrder> orderModel = db.tblOrder.OrderByDescending(x => x.Id).ToPagedList <tblOrder>(page, 10); return(View(orderModel)); }
public ActionResult Coupon(int?p, string df, string dt) { int pageSize = 30; int pageNumber = Shared.GetPageNumber(p); PagedList.IPagedList <UserinfoList> list = null; using (DatabaseContext context = new DatabaseContext()) { try { ViewBag.DateFrom = df; ViewBag.DateTo = dt; DateTime?dateFrom = null; DateTime?dateTo = null; if (!string.IsNullOrEmpty(df)) { dateFrom = Convert.ToDateTime(df, Shared.CultureInfoTh); } if (!string.IsNullOrEmpty(dt)) { dateTo = Convert.ToDateTime(dt, Shared.CultureInfoTh).AddDays(1); } var model = (from b in context.UserBillinfo join i in context.Userinfo on b.username equals i.username join rg in context.RadUsergroup on b.username equals rg.username join pl in context.Plan on b.planName equals pl.planName into pl_leftjoin from pl in pl_leftjoin.DefaultIfEmpty() where b.hotspot_id == UserOnline.HotspotId orderby b.creationdate descending select new UserinfoList { username = b.username, firstname = i.firstname, lastname = i.lastname, id_card = i.id_card, mobilephone = i.mobilephone, email = i.email, ref1 = i.ref1, ref2 = i.ref2, packagename = b.planName, groupname = rg.groupname, packageprice = string.IsNullOrEmpty(pl.planCost) ? "0" : pl.planCost, creationdate = b.creationdate }) .WhereIf(!string.IsNullOrEmpty(df), w => w.creationdate >= dateFrom) .WhereIf(!string.IsNullOrEmpty(dt), w => w.creationdate < dateTo); list = model.ToPagedList(pageNumber, pageSize); if ((pageNumber > list.PageCount) && (list.PageCount > 0)) { list = model.ToPagedList(list.PageCount, pageSize); } } catch (Exception ex) { string msgError = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; ViewBag.Error = msgError; LogManager.Error("Report.Coupon Error -> " + msgError); } } return(View(list)); }
public ActionResult Category(int page = 1) { PagedList.IPagedList <tblCategory> categoryModel = db.tblCategory.OrderByDescending(x => x.Id).ToPagedList <tblCategory>(page, 10); return(View(categoryModel)); }