Ejemplo n.º 1
0
        public ActionResult Index(string tag = "")
        {
            //Return an instance of ListingViewModel.
            List <KnowledgeBaseItem> _knowledgeBaseItemList = new List <KnowledgeBaseItem>();

            if (!String.IsNullOrEmpty(tag))
            {
                _knowledgeBaseItemList = KnowledgeQuery.GetByFilter(x => x.Tags.Contains(tag));
            }
            else
            {
                _knowledgeBaseItemList = KnowledgeQuery.GetAll();
            }

            List <QuestionAndAnswerItemModel> _questionAndAnswerItemModelList = new List <QuestionAndAnswerItemModel>();

            foreach (KnowledgeBaseItem item in _knowledgeBaseItemList)
            {
                _questionAndAnswerItemModelList.Add(new QuestionAndAnswerItemModel
                {
                    Answer       = item.Answer,
                    Id           = item.Id,
                    LastUpdateOn = item.LastUpdateOn.ToShortDateString(),
                    Question     = item.Query,
                    Tags         = item.Tags
                });
            }

            ListingViewModel model = new ListingViewModel()
            {
                Questions = _questionAndAnswerItemModelList,
                Tag       = tag
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public static List <Entities.TagItem> Process(Core.Services.IQueryService <Entities.KnowledgeBaseItem> knowledgeService, out int tagMaxCount)
        {
            var sourceItems = knowledgeService.GetAll();

            return(Process(sourceItems, out tagMaxCount));
        }