public ActionResult RatingCreate(Guid id, int rating, int maxRating, int minRating)
        {
            if (!FeatureCheckHelper.IsFeatureEnabled(FeatureNames.Feedback))
            {
                return(new EmptyResult());
            }

            var context = PortalCrmConfigurationManager.CreateServiceContext();

            var article = context.RetrieveSingle("knowledgearticle",
                                                 FetchAttribute.All,
                                                 new Condition("knowledgearticleid", ConditionOperator.Equal, id),
                                                 false,
                                                 false,
                                                 RequestFlag.AllowStaleData);

            if (article == null || !Authorized(context, article))
            {
                return(new EmptyResult());
            }

            var articleDataAdapter = new KnowledgeArticleDataAdapter(article);

            TryAddUpdateRating(articleDataAdapter, rating, maxRating, minRating);

            var commentsViewModel = new ArticleCommentsViewModel()
            {
                KnowledgeArticle = articleDataAdapter.Select()
            };

            return(PartialView("Rating", commentsViewModel.KnowledgeArticle));
        }
Beispiel #2
0
 public ArticleViewModel(Entity article, int?page, string code)
 {
     this.articleDataAdapter = new KnowledgeArticleDataAdapter(article, code)
     {
         ChronologicalComments = true
     };
     this.KnowledgeArticle       = this.articleDataAdapter.Select();
     this.relatedEntityResponses = new Lazy <IEnumerable <EntityCollection> >(this.GetRelatedArticlesAndProducts);
     this.comments = new Lazy <ArticleCommentsViewModel>(() => this.GetComments(page));
 }
        public void IncrementViewCount(Guid id, Uri urlReferrer)
        {
            var articleEntity      = new Entity("knowledgearticle", id);
            var articleDataAdapter = new KnowledgeArticleDataAdapter(articleEntity)
            {
                ChronologicalComments = true
            };

            articleDataAdapter.IncrementKnowledgeArticleViewCount(urlReferrer);
        }
        public void CaseDeflectionCreate(Guid id, bool isRatingEnabled, string searchText)
        {
            var context = PortalCrmConfigurationManager.CreateServiceContext();

            var article = context.RetrieveSingle("knowledgearticle",
                                                 FetchAttribute.All,
                                                 new Condition("knowledgearticleid", ConditionOperator.Equal, id),
                                                 false,
                                                 false,
                                                 RequestFlag.AllowStaleData);

            var articleDataAdapter = new KnowledgeArticleDataAdapter(article);

            articleDataAdapter.CreateUpdateCaseDeflection(article.Attributes["title"].ToString(), searchText, isRatingEnabled, context);
        }
        public ActionResult CommentCreate(Guid id, string authorName, string authorEmail, string copy)
        {
            if (!FeatureCheckHelper.IsFeatureEnabled(FeatureNames.Feedback))
            {
                return(new EmptyResult());
            }

            var context = PortalCrmConfigurationManager.CreateServiceContext();

            var article = context.RetrieveSingle("knowledgearticle",
                                                 FetchAttribute.All,
                                                 new Condition("knowledgearticleid", ConditionOperator.Equal, id),
                                                 false,
                                                 false,
                                                 RequestFlag.AllowStaleData);

            if (article == null || !Authorized(context, article))
            {
                return(new EmptyResult());
            }

            var articleDataAdapter = new KnowledgeArticleDataAdapter(article)
            {
                ChronologicalComments = true
            };

            var sanitizedCopy = SafeHtml.SafeHtmSanitizer.GetSafeHtml(copy ?? string.Empty);

            TryAddComment(articleDataAdapter, authorName, authorEmail, sanitizedCopy);

            var commentsViewModel = new ArticleCommentsViewModel()
            {
                Comments =
                    new PaginatedList <IComment>(PaginatedList.Page.Last, articleDataAdapter.SelectCommentCount(),
                                                 articleDataAdapter.SelectComments),
                KnowledgeArticle = articleDataAdapter.Select()
            };

            RouteData.Values["action"] = "Article";
            RouteData.Values["id"]     = Guid.Empty;
            return(PartialView("Comments", commentsViewModel));
        }