public void Delete(Guid id) { ArticleTagModel articleTag = Context.ArticleTags.Find(id); Context.ArticleTags.Remove(articleTag); Context.SaveChanges(); }
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)); }
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)); }
public CreateArticleTagsCommand(ArticleTagModel model) => ArticleTags = model;
public void Update(ArticleTagModel t) { Context.ArticleTags.Update(t); Context.SaveChanges(); }
public void Create(ArticleTagModel t) { Context.ArticleTags.Add(t); Context.SaveChanges(); }
public ActionResult CreateTagsByArticleId(ArticleTagModel model) { _mediator.Send(new CreateArticleTagsCommand(model)); return(Ok()); }