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 JsonResult AddFeedToCat(int catId, int feedId)
        {
            var feed = _feedBusiness.Get(feedId);
            var cat  = _categoryBusiness.Get(catId);

            feed.Categories.Add(cat);
            _feedBusiness.Edit(feed);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public IActionResult Get(int categoryId)
        {
            try
            {
                var category = _category.Get(categoryId);

                if (category == null)
                {
                    return(NotFound($"There is no book for Id: {categoryId}"));
                }

                return(Ok(category));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 4
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.º 5
0
        public virtual ActionResult All(string u, string c = "all", int q = 0)
        {
            ViewBag.Count = q;
            ViewBag.Cat   = c;
            int Count = ViewBag.MaxCount = 30;
            var cats  = new List <long>();

            if (!string.IsNullOrEmpty(c) && c != "all")
            {
                var catId = _categoryBusiness.Get(c).Id;
                cats = _categoryBusiness.GetList(catId).Select(cc => cc.Id).ToList();
                cats.Add(catId);
            }

            var query = _siteBusiness.GetList();

            if (cats.Any())
            {
                query = query.Where(s => s.Feeds.Any(f => f.Categories.Any(cc => cats.Contains(cc.Id))));
            }

            //var feedtop = _feedBusiness.GetList().Where(x => !x.Site.SkipType.HasValue || x.Site.SkipType == 0)
            //    .OrderBy(x => x.UpdateDurationId).Skip(q).Take(Count).Select(x => x.Id).ToList();
            var res = query.Where(s => s.Feeds.Any(x => !x.Site.SkipType.HasValue || x.Site.SkipType == 0))
                      .OrderBy(x => x.PageRank)
                      .Skip(q)
                      .Take(Count)
                      .Distinct()
                      .ToList();

            if (res.Any())
            {
                res.Last().CrawledCount = q + Count;
            }


            //View(res);

            return(View("All." + CmsConfig.ThemeName, res));
        }
Exemplo n.º 6
0
        public List <FeedItem> FeedItemsByCat(string code, int PageSize, int PageIndex, bool?hasPhoto, int CacheTime = MinCacheTime)
        {
            var cat = CatBiz.Get(code);

            return(FeedItemsByCat(cat.Id, PageSize, PageIndex, hasPhoto.HasValue ? hasPhoto : false, CacheTime));
        }
Exemplo n.º 7
0
        public virtual ActionResult Index(string Content, int PageIndex)
        {
            var model           = new CatItemsPageModel();
            var LastItemPubDate = DateTime.Now.AddMinutes(10);
            var catCurrent      = _categoryBusiness.Get(Content);

            #region ViewBag
            ViewBag.EnTityRef      = catCurrent.Id;
            ViewBag.Toggle         = "1";
            ViewBag.SearchTextDir  = "text-align:right;direction:rtl;display:none";
            ViewBag.Title          = catCurrent.Title;
            ViewBag.ImageThumbnail = catCurrent.ImageThumbnail;
            ViewBag.Content        = catCurrent.Code.Trim().ToLower();
            ViewBag.PageHeader     = "اخبار " + catCurrent.Title;
            ViewBag.KeyWords       = string.IsNullOrEmpty(catCurrent.KeyWords) ? "" : catCurrent.KeyWords.Replace("-", ",");
            ViewBag.Discription    = catCurrent.Description;
            ViewBag.CatCurrent     = catCurrent;
            ViewBag.PageIndex      = PageIndex + 1;
            ViewBag.PageCount      = 15;
            #endregion

            var allcats = _categoryBusiness.GetList(catCurrent.Id).ToList();
            allcats.Insert(0, catCurrent);
            var Id = catCurrent.Id;
            model.Items       = _feedItemBusiness.FeedItemsByCat(Id, PageSize, PageIndex, false);
            model.VisualItems = _feedItemBusiness.FeedItemsByCat(Id, _appConfigBiz.GetVisualPostCount() + _appConfigBiz.GetVisualPostCount(), PageIndex, true);
            //-----------------Sub cat-------------------
            var SubCats = allcats.Where(x => x.ParentId == catCurrent.Id).ToList();
            SubCats.ForEach(x => x.ParentId = 0);
            if (SubCats.Count() > 0)
            {
                ViewBag.Categorys = SubCats;
                var items = new List <SelectListItem>();
                items.Add(new SelectListItem {
                    Text = "همه مطالب", Value = catCurrent.Code
                });
                foreach (var SubCat in SubCats)
                {
                    items.Add(new SelectListItem {
                        Text = SubCat.Title, Value = SubCat.Code
                    });
                }
                ViewBag.SubCats = items;
            }


            var allIds = allcats.Select(x => x.Id).ToList();
            ViewBag.RelatedTags = _tagBusiness.GetList()
                                  .Where(t => t.Categories.Any(tc => allIds.Contains(tc.Id))).ToList();
            //ViewBag.RelatedTags = context.Tags.Where(x => x.TagCategories.Where(c => c.Categorie_CatCurrent == ViewBag.CatCurrent.CatCurrent || c.Categorie_CatCurrent == ViewBag.CatCurrent.ParentId).Count() > 0).ToList();

            //----------------Top Site in this Cat-------
            ViewBag.TopSites = _unitOfWork.Database.SqlQueryCache_FirstParam <SiteOnlyTitle>(120, "Sites_Select_TopByCat {0},{1}", catCurrent.Id, 15).ToList();
            if (ViewBag.TopSites == null)
            {
                ViewBag.TopSites = _siteBusiness.GetTopSites(18, 120);
            }

            model.Posts = _postBiz.GetList().Where(p => !p.MetaData.IsDeleted && p.PublishDate < DateTime.Now && p.Categories.Any(pc => pc.Id == catCurrent.Id || pc.ParentId == catCurrent.Id))
                          .Take(_appConfigBiz.GetVisualPostCount()).ToList();

            #region Tabs
            //ViewBag.RemoteWebParts = (from p in Ioc.DataContext.RemoteWebParts
            //                          where
            //                          p.Active == true &&
            //                          p.Categories.Any(x => x.Id == catCurrent.Id)
            //                          select p).ToList();

            //ViewBag.Pages = catCurrent.Posts.Where(p => p.PostType == PostType.Tab).ToList();

            #endregion

            return(View("Index." + CmsConfig.ThemeName, model));
        }
Exemplo n.º 8
0
 public virtual FileContentResult CatPhoto(int Id)
 {
     // Skipping any validation etc -to read no-photo image [if data is not present] - for simplicity
     byte[] ImagByte = _categoryBusiness.Get(Id).Icon;
     return(new FileContentResult(ImagByte, "image/png"));
 }
Exemplo n.º 9
0
        public ActionResult CategoryList()
        {
            IEnumerable <Category> categories = _categoryBusiness.Get();

            return(View(categories));
        }