public ActionResult Index(string currentFilter, string searchString, int?page) { if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; currentLinks = _linksRepository.GetLinks(); if (!String.IsNullOrEmpty(searchString)) { currentLinks = currentLinks.Where(s => s.LinkName.ToUpper().Contains(searchString.ToUpper())); } pageSize = 3; pageNumber = (page ?? 1); var OnePageOfLinks = currentLinks.ToPagedList(pageNumber, pageSize); return(View(OnePageOfLinks)); }
public ActionResult GetLinksJson(int limit, int offset, string departmentname, string statu, string search) { var listLinks = _linksRepository.GetLinks().AsQueryable(); if (!string.IsNullOrEmpty(search)) { listLinks = listLinks.Where(i => i.LinkName.Contains(search)); } var total = listLinks.Count(); var rows = from a in listLinks.OrderByDescending(i => i.LinkSort).Skip(offset).Take(limit) select new { a.Id, a.LinkName, a.LinkImg, a.LinkUrl, a.LinkSort, a.CreateTime, a.CreateUser }; return(MyJson(new { total, rows }, JsonRequestBehavior.AllowGet)); }
public IActionResult Get([FromQuery] LinkRequest request) { int requestedPage = request.Page ?? 1; int requestedPageSize = request.PageSize ?? 10; string search = request.Search ?? ""; IEnumerable <Link> links = _repository.GetLinks(search, requestedPage, requestedPageSize); int linksCountMatchedSearch = _repository.LinksCount(search); int maxPage = (linksCountMatchedSearch / requestedPageSize); maxPage += linksCountMatchedSearch % requestedPageSize == 0 ? 0 : 1; IEnumerable <LinkGetResult.SendedLinkToClient> linkInformations = links.Select(x => new LinkGetResult.SendedLinkToClient(x)); LinkGetResult result = new LinkGetResult(linkInformations, new LinkGetResult.PageInfo(requestedPage, maxPage)); return(Ok(result)); }
public IActionResult Index() { var links = _repository.GetLinks(); return(View(links)); }
public ActionResult GetLink(int count) { var x = _linksRepository.GetLinks().OrderBy(i => i.LinkSort).Take(count).ToList(); return(View(x)); }