Exemplo n.º 1
0
        public List <FeedItem> Get(string content, int pageIndex, int pageSize)
        {
            if (content.Contains("."))
            {
                var site = _siteBusiness.Get(content);
                if (site != null)
                {
                    return(_feedItemBusiness.FeedItemsBySite(site.Id, pageSize, pageIndex).ToList());
                }
            }
            else
            {
                var cat = _categoryBusiness.Get(content);
                if (cat != null)
                {
                    return(_feedItemBusiness.FeedItemsByCat(cat.Id, pageSize, pageIndex).ToList());
                }

                var tag = _tagBusiness.Get(content);
                if (tag != null)
                {
                    return(_feedItemBusiness.FeedItemsByTag(tag, pageSize, pageIndex).ToList());
                }
                else
                {
                    return(_feedItemBusiness.FeedItemsByKey(content, pageSize, pageIndex).ToList());
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public virtual ActionResult FeedItems(string content, int PageIndex)
        {
            ViewBag.Content = content;
            var TagCurrent = _tagBusiness.Get(content);

            if (TagCurrent == null)
            {
                return(RedirectToAction(MVC.Error.notfound()));
            }

            #region viewBag
            ViewBag.PageIndex  = PageIndex + 1;
            ViewBag.PageHeader = "تازه ترین های " + TagCurrent.Title;
            #endregion

            var res = _feedItemBusiness.FeedItemsByTag(TagCurrent, PageSize, PageIndex);
            return(PartialView("_FeedItems.Tazeyab", res));
        }
Exemplo n.º 3
0
        public virtual JsonResult CreateEdit(TagViewModel tag)
        {
            var poco = _tagBusiness.Get(tag.Id);

            poco = tag.ToModel <Tag>(poco);
            var res = _tagBusiness.Update(poco);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public virtual void AddTagToHistory(int TagId)
        {
            var tag = _tagBusiness.Get(TagId);

            if (tag != null)
            {
                _searchHistoryBusiness.Add(tag);
            }
        }
Exemplo n.º 5
0
        public List <FeedItem> FeedItemsByTag(string Content, int PageSize, int PageIndex, ref string TagTitle, int CacheTime = MinCacheTime)
        {
            var TagCurrent = new Tag();

            TagCurrent = TagBiz.Get(Content.Trim());
            if (TagCurrent == null)
            {
                if (TagBiz.GetList(Content).Any())
                {
                    TagCurrent = TagBiz.GetList(Content).First();
                }
            }

            if (TagCurrent != null)
            {
                Content  = TagCurrent.Value;
                TagTitle = TagCurrent.Title;
            }
            return(ItemsByKey(Content, PageSize, PageIndex));
        }
Exemplo n.º 6
0
        public virtual ActionResult Index(string Content, int PageSize)
        {
            var cat = _categoryBusiness.Get(Content);

            if (cat != null)
            {
                var allcats = _categoryBusiness.GetList(cat.Id).ToList();
                allcats.Insert(0, cat);
                var res = _feedItemBusiness.FeedItemsByCat(cat.Id, PageSize, 0);
                return(new FeedResult("تازه ترین مطالب پیرامون  " + cat.Title, res.ToList()));
            }
            var tag = _tagBusiness.Get(Content);

            if (tag != null)
            {
                var res = _feedItemBusiness.FeedItemsByTag(tag, PageSize, 0);
                return(new FeedResult("تازه ترین مطالب پیرامون  " + tag.Title, res.ToList()));
            }
            return(View());
        }
Exemplo n.º 7
0
        public virtual ActionResult Index(string content, int PageIndex = 0)
        {
            if (string.IsNullOrEmpty(content))
            {
                return(RedirectToAction(MVC.Tag.All()));
            }
            var Content         = content.Trim();
            var LastItemPubDate = DateTime.Now.AddMinutes(15);

            #region IfSite
            if (Utility.HasFaWord(Content) == false)
            {
                Content = Content.ReplaceX("www.", "");
                if (Content.CountStringOccurrences(".") == 1 || Content.CountStringOccurrences(".") == 2)
                {
                    if (Utility.UrlIsValid(Content) || Utility.UrlIsValid("www." + Content))
                    {
                        return(Redirect("/site/" + Content));
                        //return RedirectToAction(MVC.Site.ActionNames.Index, MVC.Site.Name, new { Content = Content[Content.Count() - 1] == '/' ? Content : Content + "/", PageSize = PageSize, LastItemPubDate = LastItemPubDate });
                    }
                }
            }
            #endregion

            #region IfTag
            Tag TagCurrent = null;
            try
            {
                TagCurrent = _tagBusiness.Get(Content.Replace("_", " "));
                if (TagCurrent == null)
                {
                    var tagCandidate = _tagBusiness.GetList().Where(x => x.Value.Contains(content + "|") || x.Value.Contains("|" + content)).ToList();
                    if (tagCandidate.Any())
                    {
                        TagCurrent = tagCandidate.First();
                        return(RedirectToAction(MVC.Tag.Index(TagCurrent.Title)));
                    }
                }
                else
                {
                    return(RedirectToAction(MVC.Tag.Index(TagCurrent.Title)));
                }
            }
            catch
            {
                //TagCurrent = context.Tags.Where(x => x.Value.Contains(Content)).First();
            }

            #endregion

            #region IfNotFound

            var res = new List <FeedItem>();

            res = _feedItemBusiness.FeedItemsByKey(Content, PageSize, PageIndex).ToList();

            if (res.Count() < 3)
            {
                return(RedirectToAction(MVC.Search.ActionNames.Index, MVC.Search.Name, new { Content = Content }));
            }
            #endregion

            #region ViewBag
            ViewBag.PageSize        = PageSize;
            ViewBag.Toggle          = "1";
            ViewBag.SearchTextDir   = "text-align:right;direction:rtl";
            ViewBag.Title           = Content;
            ViewBag.Content         = Content;
            ViewBag.SearchExpersion = Content;
            ViewBag.PageHeader      = "نتیجه جستجو " + Content;
            ViewBag.RecentTags      = _tagBusiness.RelevantTags(Content).ToList();
            ViewBag.PageIndex       = PageIndex + 1;
            #endregion

            if (string.IsNullOrEmpty(Content))
            {
                return(RedirectToAction(MVC.Tag.Name, MVC.Tag.ActionNames.All, null));
            }

            ViewBag.TopSites = _siteBusiness.GetTopSites(20, 120);
            res = _feedItemBusiness.DescriptClear(res, Content).ToList();

            return(View("Index." + CmsConfig.ThemeName, res));
        }