private async Task PrepareKnowledgebaseArticleModel(KnowledgebaseArticleModel model, KnowledgebaseArticle article, ICustomerService customerService)
        {
            model.Content                      = article.GetLocalized(y => y.Content, _workContext.WorkingLanguage.Id);
            model.Name                         = article.GetLocalized(y => y.Name, _workContext.WorkingLanguage.Id);
            model.Id                           = article.Id;
            model.ParentCategoryId             = article.ParentCategoryId;
            model.SeName                       = article.GetLocalized(y => y.SeName, _workContext.WorkingLanguage.Id);
            model.AllowComments                = article.AllowComments;
            model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnArticleCommentPage;
            var articleComments = await _knowledgebaseService.GetArticleCommentsByArticleId(article.Id);

            foreach (var ac in articleComments)
            {
                var customer = await customerService.GetCustomerById(ac.CustomerId);

                var commentModel = new KnowledgebaseArticleCommentModel {
                    Id                   = ac.Id,
                    CustomerId           = ac.CustomerId,
                    CustomerName         = customer.FormatUserName(_customerSettings.CustomerNameFormat),
                    CommentText          = ac.CommentText,
                    CreatedOn            = _dateTimeHelper.ConvertToUserTime(ac.CreatedOnUtc, DateTimeKind.Utc),
                    AllowViewingProfiles = _customerSettings.AllowViewingProfiles && customer != null && !customer.IsGuest(),
                };
                if (_customerSettings.AllowCustomersToUploadAvatars)
                {
                    commentModel.CustomerAvatarUrl = await _pictureService.GetPictureUrl(
                        customer.GetAttributeFromEntity <string>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mediaSettings.AvatarPictureSize,
                        _customerSettings.DefaultAvatarEnabled,
                        defaultPictureType : PictureType.Avatar);
                }

                model.Comments.Add(commentModel);
            }

            foreach (var id in article.RelatedArticles)
            {
                var a = await _knowledgebaseService.GetPublicKnowledgebaseArticle(id);

                if (a != null)
                {
                    model.RelatedArticles.Add(new KnowledgebaseArticleModel {
                        SeName = a.SeName,
                        Id     = a.Id,
                        Name   = a.Name
                    });
                }
            }

            var category = await _knowledgebaseService.GetKnowledgebaseCategory(article.ParentCategoryId);

            if (category != null)
            {
                string breadcrumbCacheKey = string.Format(ModelCacheEventConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY,
                                                          article.ParentCategoryId,
                                                          string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
                                                          _storeContext.CurrentStore.Id,
                                                          _workContext.WorkingLanguage.Id);
                model.CategoryBreadcrumb = await _cacheManager.GetAsync(breadcrumbCacheKey, async() =>
                                                                        (await category.GetCategoryBreadCrumb(_knowledgebaseService, _aclService, _storeMappingService))
                                                                        .Select(catBr => new KnowledgebaseCategoryModel {
                    Id = catBr.Id,
                    Name = catBr.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id),
                    SeName = catBr.GetSeName(_workContext.WorkingLanguage.Id)
                })
                                                                        .ToList()
                                                                        );
            }
        }
        private async Task PrepareKnowledgebaseArticleModel(KnowledgebaseArticleModel model, KnowledgebaseArticle article, ICustomerService customerService)
        {
            model.Content                      = article.GetLocalized(y => y.Content, _workContext.WorkingLanguage.Id);
            model.Name                         = article.GetLocalized(y => y.Name, _workContext.WorkingLanguage.Id);
            model.Id                           = article.Id;
            model.ParentCategoryId             = article.ParentCategoryId;
            model.SeName                       = article.GetLocalized(y => y.SeName, _workContext.WorkingLanguage.Id);
            model.AllowComments                = article.AllowComments;
            model.AddNewComment.DisplayCaptcha = _captchaSettings.Enabled && _captchaSettings.ShowOnArticleCommentPage;

            model.MetaTitle       = article.GetLocalized(y => y.MetaTitle, _workContext.WorkingLanguage.Id);
            model.MetaDescription = article.GetLocalized(y => y.MetaDescription, _workContext.WorkingLanguage.Id);
            model.MetaKeywords    = article.GetLocalized(y => y.MetaKeywords, _workContext.WorkingLanguage.Id);

            var articleComments = await _knowledgebaseService.GetArticleCommentsByArticleId(article.Id);

            foreach (var ac in articleComments)
            {
                var customer = await customerService.GetCustomerById(ac.CustomerId);

                var commentModel = new KnowledgebaseArticleCommentModel {
                    Id           = ac.Id,
                    CustomerId   = ac.CustomerId,
                    CustomerName = customer.FormatUserName(_customerSettings.CustomerNameFormat),
                    CommentText  = ac.CommentText,
                    CreatedOn    = _dateTimeHelper.ConvertToUserTime(ac.CreatedOnUtc, DateTimeKind.Utc),
                };
                model.Comments.Add(commentModel);
            }

            foreach (var id in article.RelatedArticles)
            {
                var a = await _knowledgebaseService.GetPublicKnowledgebaseArticle(id);

                if (a != null)
                {
                    model.RelatedArticles.Add(new KnowledgebaseArticleModel {
                        SeName = a.SeName,
                        Id     = a.Id,
                        Name   = a.Name
                    });
                }
            }

            var category = await _knowledgebaseService.GetKnowledgebaseCategory(article.ParentCategoryId);

            if (category != null)
            {
                string breadcrumbCacheKey = string.Format(ModelCacheEventConst.KNOWLEDGEBASE_CATEGORY_BREADCRUMB_KEY,
                                                          article.ParentCategoryId,
                                                          string.Join(",", _workContext.CurrentCustomer.GetCustomerRoleIds()),
                                                          _storeContext.CurrentStore.Id,
                                                          _workContext.WorkingLanguage.Id);
                model.CategoryBreadcrumb = await _cacheBase.GetAsync(breadcrumbCacheKey, async() =>
                                                                     (await category.GetCategoryBreadCrumb(_knowledgebaseService, _aclService, _storeMappingService))
                                                                     .Select(catBr => new KnowledgebaseCategoryModel {
                    Id = catBr.Id,
                    Name = catBr.GetLocalized(x => x.Name, _workContext.WorkingLanguage.Id),
                    SeName = catBr.GetSeName(_workContext.WorkingLanguage.Id)
                })
                                                                     .ToList()
                                                                     );
            }
        }