Esempio n. 1
0
        public void Delete(Guid id)
        {
            ArticleTagModel articleTag = Context.ArticleTags.Find(id);

            Context.ArticleTags.Remove(articleTag);
            Context.SaveChanges();
        }
Esempio n. 2
0
        public ActionResult ArticleTags(int articleId)
        {
            var article = _articleService.GetArticleById(articleId);

            if (article == null)
            {
                throw new ArgumentException("No article found with the specified id");
            }

            var cacheKey   = string.Format(ModelCacheEventConsumer.ARTICLETAG_BY_ARTICLE_MODEL_KEY, article.Id, _services.WorkContext.WorkingLanguage.Id, _services.SiteContext.CurrentSite.Id);
            var cacheModel = _services.Cache.Get(cacheKey, () =>
            {
                var model = article.ArticleTags
                            //filter by site
                            .Where(x => _articleTagService.GetArticleCount(x.Id, _services.SiteContext.CurrentSite.Id) > 0)
                            .Select(x =>
                {
                    var ptModel = new ArticleTagModel()
                    {
                        Id           = x.Id,
                        Name         = x.GetLocalized(y => y.Name),
                        SeName       = x.GetSeName(),
                        ArticleCount = _articleTagService.GetArticleCount(x.Id, _services.SiteContext.CurrentSite.Id)
                    };
                    return(ptModel);
                })
                            .ToList();
                return(model);
            });

            return(PartialView(cacheModel));
        }
Esempio n. 3
0
        public virtual int GetFontSize(ArticleTagModel productTag)
        {
            double mean        = 0;
            var    itemWeights = new List <double>();

            foreach (var tag in Tags)
            {
                itemWeights.Add(tag.ArticleCount);
            }
            double stdDev = StdDev(itemWeights, out mean);

            return(GetFontSize(productTag.ArticleCount, mean, stdDev));
        }
        public ActionResult ArticlesTagsAll()
        {
            var model = new PopularArticlesTagsModel();

            model.Tags = _articlesTagService
                         .GetAllArticleTags()
                         //filter by current site
                         .Where(x => _articlesTagService.GetArticleCount(x.Id, _services.SiteContext.CurrentSite.Id) > 0)
                         //sort by name
                         .OrderBy(x => x.GetLocalized(y => y.Name))
                         .Select(x =>
            {
                var ptModel = new ArticleTagModel
                {
                    Id           = x.Id,
                    Name         = x.GetLocalized(y => y.Name),
                    SeName       = x.GetSeName(),
                    ArticleCount = _articlesTagService.GetArticleCount(x.Id, _services.SiteContext.CurrentSite.Id)
                };
                return(ptModel);
            })
                         .ToList();
            return(View(model));
        }
Esempio n. 5
0
 public CreateArticleTagsCommand(ArticleTagModel model) => ArticleTags = model;
Esempio n. 6
0
 public void Update(ArticleTagModel t)
 {
     Context.ArticleTags.Update(t);
     Context.SaveChanges();
 }
Esempio n. 7
0
 public void Create(ArticleTagModel t)
 {
     Context.ArticleTags.Add(t);
     Context.SaveChanges();
 }
Esempio n. 8
0
        public ActionResult CreateTagsByArticleId(ArticleTagModel model)
        {
            _mediator.Send(new CreateArticleTagsCommand(model));

            return(Ok());
        }