예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        public IActionResult Index()
        {
            var links = _repository.GetLinks();

            return(View(links));
        }
예제 #5
0
        public ActionResult GetLink(int count)
        {
            var x = _linksRepository.GetLinks().OrderBy(i => i.LinkSort).Take(count).ToList();

            return(View(x));
        }