Exemplo n.º 1
0
 protected override void InitialQuery(FaqQueryViewModel model)
 {
     using (ContextManager.NewConnection())
     {
         var categories = Mapper.Map <List <FaqCategoryViewModel> >(faqService.SearchFaqCategories());
         model.CategoryDataSource = categories
                                    .Select(
             item => new KeyValuePair <string, string>(item.Id?.ToString(), item.Name))
                                    .ToList().AddDefaultValue();
         model.StatusDataSource = nomenclatureService.Get("nfaqstatus")
                                  .Select(
             item => new KeyValuePair <string, string>(item.Id?.ToString(), item.Name))
                                  .ToList().AddDefaultValue();
     }
 }
Exemplo n.º 2
0
        private void InitFAQMenuItems(List <Page> allowPages)
        {
            var faqPage = allowPages.FirstOrDefault(
                page =>
                page.PageType == PageType.Link &&
                page.PermanentLink.IsNotNullOrEmpty() &&
                Regex.IsMatch(page.PermanentLink, @"^\/*faq\/*$", RegexOptions.IgnoreCase));

            if (faqPage != null)
            {
                List <FaqCategory> faqCategories;
                using (ContextManager.NewConnection())
                {
                    faqCategories = faqService.SearchFaqCategories();
                }

                if (faqCategories.IsNotNullOrEmpty())
                {
                    faqPage.PermanentLink = "#";
                    foreach (var faqCategory in faqCategories.Where(x => x.HasQuestions))
                    {
                        allowPages.Add(
                            new Page
                        {
                            Id             = faqCategory.Id,
                            ParentId       = faqPage.Id,
                            Titles         = faqCategory.Names,
                            Type           = faqPage.Type,
                            VisibilityType = faqPage.VisibilityType,
                            LocationType   = faqPage.LocationType,
                            IsInNewWindow  = faqPage.IsInNewWindow,
                            PermanentLink  = Url.DynamicAction("Faq", typeof(HomeController), new { categoryId = faqCategory.Id }, absoluteUrl: true)
                        });
                    }
                }
            }
        }