Ejemplo n.º 1
0
        // GET: Links
        public IActionResult Index(int page = 0, int pageSize = 10, string tagId = null, string extSearch = null)
        {
            ViewData["Page"] = page;
            var links = _linksService.GetUserLinks(page, pageSize, User, tagId).ToList();

            if (!string.IsNullOrEmpty(extSearch))
            {
                links = links.Where(_ => Regex.IsMatch(_.Description, extSearch, RegexOptions.IgnoreCase) ||
                                    Regex.IsMatch(_.Order.ToString(), extSearch, RegexOptions.IgnoreCase) ||
                                    Regex.IsMatch(_.Url, extSearch, RegexOptions.IgnoreCase) ||
                                    _.LinkTags.Select(t => t.Tag).Any(tag => Regex.IsMatch(tag.Name, extSearch, RegexOptions.IgnoreCase))).ToList();
            }
            IEnumerable <Tag> tags = new List <Tag>();

            if (links.Any())
            {
                tags = _linksService.GetMostUsedTags(links);
            }
            return(View(new LinkIndexViewModel
            {
                Link = links,
                Tags = tags
            }));
        }