public ActionResult Set(int?page) { var auctions = db.Auction.Where(a => a.Status == "READY"); int perPage = db.Admin.FirstOrDefault().NumberOfProductsPage; int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(auctions.ToList(), pageNumber, perPage))); }
// // GET: /Account/WonAuctions public ActionResult WonAuctions(int?lowPrice, int?highPrice, int?page, string currentFilter, string search, int?NumberOfProductsPage) { if (search != null) { page = 1; } else { search = currentFilter; } ViewBag.CurrentFilter = search; // User user = Session["User"] as User; string userId = User.Identity.GetUserId(); int Id = db.User.Where(u => u.idAspNetUsers == userId).FirstOrDefault().Id; var auction = db.Auction.Where(a => (a.Status == "COMPLETED") && (a.User.Id == Id)); if (highPrice != null) { ViewBag.High = highPrice; auction = auction.Where(a => a.CurrentPrice < highPrice); } if (lowPrice != null) { ViewBag.Low = lowPrice; auction = auction.Where(a => a.CurrentPrice > lowPrice); } List <Auction> aukcije = new List <Auction>(); if (search != null) { var words = search.Split(' '); foreach (var a in auction) { foreach (var w in words) { if (a.Name.ToLower().Contains(w.ToLower())) { aukcije.Add(a); } } } } else { aukcije = auction.ToList(); } ViewBag.NumberOfProductsPage = NumberOfProductsPage != null ? NumberOfProductsPage : db.Admin.FirstOrDefault().NumberOfProductsPage; int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(aukcije.Distinct(), pageNumber, ViewBag.NumberOfProductsPage))); }
public ActionResult Health_Providers(string ct, int?page) { ViewBag.HList = ct; ViewBag.Action = "Health_Providers"; currentPageIndex = page.HasValue ? page.Value : 1; var providers = db.ING_Hospital_List.Where(h => h.category == ct).OrderBy(p => p.Hospital); return(View(PagedListExtensions.ToPagedList(providers, currentPageIndex, DefaultPageSize))); }
public ActionResult TokenOrders(int?page) { User user = Session["User"] as User; IList <TokenOrder> orders = db.tokenOrders.Where(t => t.userId == user.id).OrderByDescending(t => t.dateSubmitted).ToList(); AdminSettings admin = db.adminSettings.FirstOrDefault(); int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(orders, pageNumber, admin.N))); }
public ActionResult MyOrders(int?page) { // User user = Session["User"] as User; string userId = User.Identity.GetUserId(); int Id = db.User.Where(u => u.idAspNetUsers == userId).FirstOrDefault().Id; int perPage = db.Admin.FirstOrDefault().NumberOfProductsPage; var order = db.TokenOrder.Where(t => t.UserId == Id); int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(order.ToList(), pageNumber, perPage))); }
public ActionResult Search_Health_Providers(int?page, string ct, string searchTerm) { ViewBag.HList = ct; ViewBag.searchTerm = searchTerm; ViewBag.Action = "Search_Health_Providers"; currentPageIndex = page.HasValue ? page.Value : 1; var providers = db.ING_Hospital_List.Where(cb => (cb.Hospital.Contains(searchTerm) || cb.City.Contains(searchTerm) || cb.Speciality.Contains(searchTerm) || cb.State.Contains(searchTerm)) && cb.category == ct) .OrderBy(b => b.Hospital); return(View("Health_Providers", PagedListExtensions.ToPagedList(providers, currentPageIndex, DefaultPageSize))); }
public async Task <PagedList <Contact> > GetAsync(int pageNumber = 1, int pageSize = 30) { var contacts = _dbContext.Contacts.Include(c => c.TelephoneNumbers) as IQueryable <Contact>; return(await PagedListExtensions.Create(contacts, pageNumber, pageSize)); }
public ActionResult AllAuctions(string CurrentFilter, string searchStringOrPartOfString, int?priceFrom, int?priceTo, int?itemsPerPage, string wayOfSorting, int?page) { if (searchStringOrPartOfString != null) { page = 1; } else { searchStringOrPartOfString = CurrentFilter; } ViewBag.CurrentFilter = searchStringOrPartOfString; ViewBag.itemsPerPage = itemsPerPage != null ? itemsPerPage : db.adminSettings.FirstOrDefault().N; ViewBag.Message = "All auctions:"; var auctions = from a in db.auctions select a; if (auctions != null) { switch (wayOfSorting) { case "ascending": auctions = auctions.OrderBy(a => a.name); break; case "descending": auctions = auctions.OrderByDescending(a => a.name); break; case "price_asc": auctions = auctions.OrderBy(a => a.currPrice); break; case "price_desc": auctions = auctions.OrderByDescending(a => a.currPrice); break; case "READY": auctions = auctions.Where(a => a.status == "READY"); break; case "OPENED": auctions = auctions.Where(a => a.status == "OPENED"); break; case "COMPLETED": auctions = auctions.Where(a => a.status == "COMPLETED"); break; default: auctions = auctions.OrderBy(a => a.timeOpened).Take(10); break; } ViewBag.wayOfSorting = wayOfSorting; ViewBag.priceFrom = priceFrom; ViewBag.priceTo = priceTo; ViewBag.searchStringOrPartOfString = searchStringOrPartOfString; if (priceFrom != null) { auctions = auctions.Where(a => a.currPrice > priceFrom); } if (priceTo != null) { auctions = auctions.Where(a => a.currPrice < priceTo); } if (searchStringOrPartOfString != null && searchStringOrPartOfString != "") { var listOfWords = searchStringOrPartOfString.Split(' '); foreach (var oneWord in listOfWords) { auctions = auctions.Where(a => a.name.ToLower().Contains(oneWord.ToLower())); } } } if (auctions == null) { return(RedirectToAction("Index", "Home")); } int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(auctions.ToList().Distinct(), pageNumber, ViewBag.itemsPerPage))); }
public ActionResult UserIndex(string currentFilter, string search, int?lowPrice, int?highPrice, int?NumberOfProductsPage, string status, int?page) { IList <Auction> auctions = db.Auction.Where(a => a.Status == "OPENED").ToList(); if (search != null) { page = 1; } else { search = currentFilter; } ViewBag.CurrentFilter = search; foreach (var a in auctions) { if ((DateTime.Now - a.DateTimeOpened.Value).TotalSeconds > a.Duration) { Bid bid = a.Bid.LastOrDefault(); if (bid != null) { a.User = bid.User; } a.DateTimeClosed = DateTime.Now; a.Status = "COMPLETED"; db.Entry(a).State = EntityState.Modified; db.SaveChanges(); } } // List<Auction> aukcije = new List<Auction>(); if ((status == null || status == "") && NumberOfProductsPage == null && (search == null || search == "") && highPrice == null && lowPrice == null) { var auction = from a in db.Auction select a; List <Auction> aukcije = new List <Auction>(); aukcije = auction.ToList(); ViewBag.NumberOfProductsPage = NumberOfProductsPage != null ? NumberOfProductsPage : db.Admin.FirstOrDefault().NumberOfProductsPage; int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(aukcije.Distinct(), pageNumber, ViewBag.NumberOfProductsPage))); } // aukcije = db.Auction.ToList(); else { var auction = from a in db.Auction select a; if (status != null && status != "") { auction = auction.Where(a => a.Status == status); } ViewBag.Status = status; if (highPrice != null) { auction = auction.Where(a => a.CurrentPrice < highPrice); } ViewBag.High = highPrice; if (lowPrice != null) { auction = auction.Where(a => a.CurrentPrice > lowPrice); } ViewBag.Low = lowPrice; List <Auction> aukcije = new List <Auction>(); if (search != null && search != "") { var words = search.Split(' '); foreach (var a in auction) { foreach (var w in words) { if (a.Name.ToLower().Contains(w.ToLower())) { aukcije.Add(a); } } } } else { aukcije = auction.ToList(); } ViewBag.NumberOfProductsPage = NumberOfProductsPage != null ? NumberOfProductsPage : db.Admin.FirstOrDefault().NumberOfProductsPage; int pageNumber = (page ?? 1); return(View(PagedListExtensions.ToPagedList(aukcije.Distinct(), pageNumber, ViewBag.NumberOfProductsPage))); } }