public virtual JsonResult CreateEdit(FeedViewModel model) { OperationStatus res; var feeddb = new Feed(); if (model.Id > 0) { feeddb = _feedBusiness.Get(model.Id); var lastUpdateDateTime = feeddb.LastUpdateDateTime; var lastUpdaterVisit = feeddb.LastUpdaterVisit; feeddb = model.ToModel <Feed>(feeddb); feeddb.LastUpdateDateTime = lastUpdateDateTime; feeddb.LastUpdaterVisit = lastUpdaterVisit; } else { feeddb = model.ToModel <Feed>(); } if (model.SelectedCategories != null) { feeddb.Categories.AddEntities(_categoryBusiness.GetList(model.SelectedCategories.ToList()).ToList()); } if (model.SelectedTags != null) { feeddb.Tags.AddEntities(_tagBusiness.GetList().Where(t => model.SelectedTags.Contains(t.Id)).ToList()); } res = _feedBusiness.CreateEdit(feeddb); return(Json(res.ToJOperationResult(), JsonRequestBehavior.AllowGet)); }
public virtual JsonResult Manage(AdsModel model) { model.CreationDate = model.CreationDate.ToEnglish(); model.ExpireDate = model.ExpireDate.ToEnglish(); var res = new OperationStatus(); if (ModelState.IsValid) { Ad ads; if (model.Id > 0) { var dbAds = _adsBiz.GetList().SingleOrDefault(a => a.Id == model.Id); ads = model.ToModel <Ad>(dbAds); } else { ads = model.ToModel <Ad>(); } if (model.SelectedCategories != null) { ads.Categories.AddEntities(_categoryBusiness.GetList(model.SelectedCategories.ToList()).ToList()); } if (model.SelectedTags != null) { ads.Tags.AddEntities(_tagBusiness.GetList().Where(t => model.SelectedTags.Contains(t.Id)).ToList()); } res = _adsBiz.CreateEdit(ads); } return(Json(res.ToJOperationResult(), JsonRequestBehavior.AllowGet)); }
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)); }
public virtual ActionResult Index() { var model = new ReaderModel(); var membership = new WebLogic.CmsMembership(_userBusiness); var MUser = membership.GetCurrentUser(); model.UserTitle = membership.GetCurrentUserTitle(); ViewBag.Title = "صفحه شخصی " + model.UserTitle; model.Tags = _tagBusiness.GetList() .Where(x => x.Users.Any(c => c.Id == MUser.Id)).Select(t => new TagViewModel() { Id = t.Id, Title = t.Title, EnValue = t.EnValue }).ToList(); model.Categories = _categoryBusiness.GetList().Where(x => x.Users.Any(c => c.Id == MUser.Id)). Select(c => new CategoryViewModel { Id = c.Id, Title = c.Title, Code = c.Code, ParentId = c.ParentId }) .ToList(); model.Categories.ForEach(x => x.ParentId = x.ParentId > 0 && model.Categories.Any(y => y.Id == x.ParentId) ? x.ParentId : 0); model.Sites = _siteBusiness.GetList().Where(x => x.Users.Any(c => c.Id == MUser.Id)) .Select(x => new SiteOnlyTitle { Id = x.Id, SiteUrl = x.SiteUrl, SiteTitle = x.SiteTitle }).ToList(); model.RecomendTags = _recomendBiz.Tags(10, model.Tags.Select(t => t.Id).ToList()).Select(t => new TagViewModel() { Id = t.Id, Title = t.Title, EnValue = t.EnValue }).ToList(); model.RecomendCats = _recomendBiz.Cats(5).Select(c => new CategoryViewModel() { Id = c.Id, Title = c.Title, Code = c.Code }).ToList(); model.RecomendSites = _recomendBiz.Sites(10, model.Sites.Select(s => s.Id).ToList()); return(View("Index." + CmsConfig.ThemeName, model)); }
public IActionResult Index(int page = 1) { int pageSize = 8; int count = 0; List <Tag> tagList = _tagBusiness.GetList(); var dataList = _articleBusiness.GetPageList(pageSize, page, out count, m => m.IsPublish == true); List <ArticleListModel> articleList = dataList .OrderByDescending(m => m.CreateTime) .Select(m => new ArticleListModel { Id = m.Id, Title = m.Title, Cover = m.Cover, PageView = m.PageView }) .ToList(); ViewBag.TagList = tagList; ViewBag.PageIndex = page; ViewBag.TotalPage = (int)Math.Ceiling(count / (decimal)pageSize); return(View(articleList)); }
List <TagCatModel> ICategoryBusiness.AllCatsTags_Cache(int tagCount, int minutes = 120) { var cats = GetList().Select(c => new TagCatModel() { Link = "cat/" + c.Code, Title = c.Title, Color = c.Color }).ToList(); var tags = _tagBusiness.GetList().Shuffle().Take(tagCount).Select(c => new TagCatModel() { Link = "tag/" + c.Value, Title = c.Title, Color = c.Color }).ToList(); cats.AddRange(tags); if (HttpContext.Current.Cache.Get("AllCatsTags_Cache") == null) { HttpContext.Current.Cache.Insert("AllCatsTags_Cache", cats, null, DateTime.Now.AddMinutes(minutes), System.Web.Caching.Cache.NoSlidingExpiration); } return((List <TagCatModel>)HttpContext.Current.Cache.Get("AllCatsTags_Cache")); }
public virtual JsonResult Manage(PostModel model) { OperationStatus res = new OperationStatus(); if (ModelState.IsValid) { Post post; if (model.Id > 0) { var dbPost = _postBiz.Get(model.Id); var oldContent = dbPost.Content + ""; post = model.ToModel <Post>(dbPost); } else { post = model.ToModel <Post>(); } if (model.SelectedCategories.Any()) { post.Categories.AddEntities(_categoryBusiness.GetList(model.SelectedCategories.ToList()).ToList()); } if (model.SelectedTags.Any()) { post.Tags.AddEntities(_tagBusiness.GetList().Where(t => model.SelectedTags.Contains(t.Id)).ToList()); } post.Content = HttpUtility.HtmlDecode(post.Content);// post.PostType == PostType.Tab ? oldContent : HttpUtility.HtmlDecode(post.Content); if (!string.IsNullOrEmpty(model.PostImage) && HttpUtility.HtmlDecode(model.PostImage).ToLower().Contains("src")) { post.PostImage = Regex.Match(HttpUtility.HtmlDecode(model.PostImage), "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value.ToLower(); } else { post.PostImage = string.Empty; } res = _postBiz.CreateEdit(post); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public virtual ActionResult Demo(string Content, string PagePath, string Title) { //TazehaContext context = new TazehaContext(); ToolBoxDemo model = new ToolBoxDemo(); if (string.IsNullOrEmpty(Content)) { } if (string.IsNullOrEmpty(PagePath)) { PagePath = "/cat/politics"; } model.Tags = _tagBusiness.GetList().ToList(); model.Tags.Insert(0, new Tag() { Title = "همه موارد", EnValue = "AllItems" }); model.Cats = _categoryBusiness.GetList().ToList(); var src = string.Empty; if (!string.IsNullOrEmpty(PagePath)) { src = string.Format("http://{0}/toolbox/script/?src={1}", Resources.Core.SiteUrl, PagePath[0] == '/' ? PagePath.Remove(0, 1) : PagePath); } model.Script = string.Format("<a href='http://" + Resources.Core.SiteUrl + "/cat/politics'>{0}</a><script type='text/javascript' src='{1}'></script>", "تازه ترین خبرهای سیاسی", src); model.Content = Content; model.Title = Title; model.PagePath = PagePath; if (!string.IsNullOrEmpty(PagePath)) { model.IframeSrc = string.Format("{0}", PagePath.ReplaceAnyCase("cat/", "cat/itemsremote/").ReplaceAnyCase("tag/", "tag/itemsremote/").ReplaceAnyCase("site/", "site/itemsremote/")); } else { model.IframeSrc = "http://" + Resources.Core.SiteUrl + "/cat/itemsremote/news"; } return(View(model)); }
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)); }
public virtual ActionResult Index() { ViewBag.Tags = _tagBusiness.GetList().ToList().Select(t => t.ToViewModel <TagViewModel>()).ToList();//.Select(t => new { t.Id, t.Title }) return(View()); }
public virtual ActionResult Index() { var Model = new HomeViewModel(); #region colors Model.Colors = new List <string> { "rgba(8, 134, 190, 0.8)", "rgba(130, 181, 71, 0.8)", "rgba(120, 66, 147, 0.8) ", "rgba(255, 0, 57, 0.8)", "rgba(255, 117, 24, 0.8)", "rgba(39, 128, 227, 0.8)", "rgba(20, 156, 130, 0.8)", "rgba(153, 84, 187, 0.8)" }; Model.Colors.Reverse(); Model.Colors.AddRange(Model.Colors); Model.Colors.Reverse(); Model.Colors.AddRange(Model.Colors); #endregion #region ViewBag ViewBag.Title = "رسانه خبری"; ViewBag.Description = "تازه ترین و جدیدترین اخبار و فایل های صوتی و تصویری"; ViewBag.KeyWords = @"اخبار روز, اخبار ورزشی ,جدیدترین رادیوها,دانلود سخنرانی, خبرخوان,موتور جستجو,نرم افزار موبایل,farsi media"; ViewBag.EntityCode = "Home"; ViewBag.EntityRef = 0; ViewBag.defaultIndex = 1; #endregion #region Top Tags var itags = HttpContext.Cache.Get("IndexTags"); if (itags != null) { Model.TopTags = HttpContext.Cache.Get("IndexTags") as List <Tag>; } else { Model.TopTags = _tagBusiness.GetList().Where(t => t.InIndex && !string.IsNullOrEmpty(t.ImageThumbnail)).Shuffle().Take(40).ToList(); HttpContext.Cache.AddToCache("IndexTags", Model.TopTags, 40); } #endregion #region Items var cats = _categoryBusiness.GetList() .Where(x => x.ViewMode == Common.Share.ViewMode.Index || x.ViewMode == Common.Share.ViewMode.MenuIndex) .OrderByDescending(x => x.Priority).ToList(); foreach (var cat in cats.Take(8)) { var sliderModel = new SliderModel() { Code = cat.Code }; if (_appConfigBiz.GetConfig <bool>(Constants.EnabledOptions.IndexPhotoHeadlines)) { sliderModel.Items = _feedItemBusiness.GetList().Where(i => i.Feed.Categories.Any(c => (c.Id == cat.Id || c.ParentId == cat.Id) && i.HasPhoto)) .OrderByDescending(i => i.PubDate).Take(4).ToList().Select(i => new SliderItemModel() { Description = i.Description, Link = string.Concat("/site/", i.SiteUrl, "/", i.ItemId, "/", i.Title.RemoveBadCharacterInURL()), ImageURL = string.Concat("/", _appConfigBiz.VisualItemsPathVirtual().ToLower(), "/", i.Id, ".jpg"), PubDate = i.PubDate.Value, Title = i.Title, VisitsCount = i.VisitsCount, Refrence = i.SiteTitle }).ToList(); } var res = _feedItemBusiness.FeedItemsByCat(cat.Id, 12, 0, 10).ToList(); Model.CatItems.Add(new HomeItemsPanelViewModel() { ShowMoreBtn = true, Cat = cat, Items = res.ToList(), slider = sliderModel }); } Model.Categories = _categoryBusiness.GetList().Where(x => x.ViewMode != Common.Share.ViewMode.NotShow).ToList(); #endregion #region Post //Model.Posts = _postBiz.GetList().Where(p => p.PostType == PostType.News && !p.MetaData.IsDeleted && p.PublishDate <= DateTime.Now) // .Select(p => new PostModel() // { // Id = p.Id, // Title = p.Title, // SubTitle = p.SubTitle, // PublishDate = p.PublishDate, // PostImage = p.PostImage, // VisitCount = p.VisitCount, // LikeCount = p.LikeCount, // DislikeCount = p.DislikeCount, // }).Take(Ioc.AppConfigBiz.GetConfig<int>(Constants.Home.VisualPostCount)).ToList(); //Model.Videos = _postBiz.GetList().Where(p => p.PostType == PostType.Video && !p.MetaData.IsDeleted && p.PublishDate <= DateTime.Now) // .Select(p => new PostModel() // { // Id = p.Id, // Title = p.Title, // SubTitle = p.SubTitle, // PublishDate = p.PublishDate, // PostImage = p.PostImage, // VisitCount = p.VisitCount, // LikeCount = p.LikeCount, // DislikeCount = p.DislikeCount, // }).Take(Ioc.AppConfigBiz.GetConfig<int>(Constants.Home.VisualPostCount)).ToList(); #endregion #region MostVisited var mosteItems = _feedItemBusiness.MostVisitedItems("today", 10, 15, 10).ToList(); // if (mosteItems != null && mosteItems.Any()) Model.MostVisitedItems = new HomeItemsPanelViewModel() { Items = mosteItems.ToList(), Cat = new Category() { Code = "news", Title = "پربازدیدترین ها", Color = Model.Colors[2] }, // CssClass = "col-md-4", ShowMoreBtn = false }; #endregion #region Top Site Model.TopSites = _siteBusiness.GetTopSites(20, 120); #endregion return(View("Index." + CmsConfig.ThemeName, Model)); }
/// <summary> /// 获取数据列表 /// </summary> /// <param name="condition">查询类型</param> /// <param name="keyword">关键字</param> /// <returns></returns> public ActionResult GetAllTagList() { var dataList = _tagBusiness.GetList(); return(Content(dataList.ToJson())); }
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)); }