Exemplo n.º 1
0
 public static List<CMSMenuModel> MapCountries(List<tbl_Domains> domains)
 {
     return domains.Select(domain => new CMSMenuModel
         {
             Title = "Countries for " + domain.DO_CompanyName,
             MenuItems = domain.tbl_Country.OrderBy(m => m.C_Order).Select(item =>
             {
                 var menuItem = new CMSMenuItem
                 {
                     MenuItemID = item.CountryID,
                     IsMove = true,
                 };
                 if (item.C_IsDefault)
                     menuItem.BoldedTitle = item.C_Country;
                 else
                     menuItem.Title = item.C_Country;
                 return menuItem;
             }).ToList()
         }).ToList();
 }
Exemplo n.º 2
0
        private static List<CMSMenuItem> CreateSectionsSubMenu(IEnumerable<tbl_SiteMap> sections, int parentID, CustomPrincipal currentUser)
        {
            return sections.Where(sm => parentID == 0 ?
                    (sm.SM_ParentID == 0 || sm.IsDirectlyInMenu) :
                    (sm.SM_ParentID == parentID && sm.IsUnderParentInMenu))
                .OrderBy(sm => sm.SM_OrderBy).Select(section =>
                 {
                     var item = new CMSMenuItem
                     {
                         MenuItemID = section.SiteMapID,
                         SubMenuItems = CreateSectionsSubMenu(sections, section.SiteMapID, currentUser),
                         CssClasses = section.SM_IsPredefined ? "predefinedSection" : String.Empty,

                         IsDelete = !section.tbl_ContentType.CTP_Value.Equals(ContentType.Category.ToString()),
                         IsEdit = !section.tbl_ContentType.CTP_Value.Equals(ContentType.Category.ToString()),
                         IsMove = currentUser.HasPermission(Permission.EditContent),
                         ApproveText = String.Format("{0} Content Requires Approval", section.SM_Name),
                         DeleteText = String.Format("Delete {0} ({1})", section.SM_Name, section.SiteMapID),
                         EditText = String.Format("Edit {0} ({1})", section.SM_Name, section.SiteMapID),
                         EditImagesText = String.Format("Images for {0} ({1})", section.SM_Name, section.SiteMapID),
                         ExpandText = String.Format("Show Sub Pages of {0}", section.SM_Name),

                         PreviewText = String.Format("Preview {0}", section.SM_Name),
                         PreviewUrl = String.Format("/Admn/Preview?sectionID={0}", section.SiteMapID),

                         Title = section.SM_Name,
                     };
                     if (section.IsType(ContentType.Category))
                     {
                         item.Title += " (Product Category)";
                     }
                     else if (section.IsType(ContentType.Gallery) && section.tbl_Gallery.G_CustomerID==0)
                     {
                         item.Title += " (Gallery)";
                     }
                     else
                     {
                         item.IsPreview = true;
                         item.IsApprove = section.tbl_Content.Where(c => !c.C_Deleted).All(c => !c.C_Approved) &&
                             currentUser.HasPermission(Permission.ApproveContent);
                         item.IsEdit = currentUser.HasPermission(Permission.EditContent);
                         item.IsExpand = sections.Any(c => c.SM_ParentID == section.SiteMapID);
                         item.IsEditImages = currentUser.HasPermission(Permission.EditContent);
                         if (!section.SM_IsPredefined)
                         {
                             item.IsDelete = currentUser.HasPermission(Permission.DeleteContent);
                         }
                     }
                     return item;
                 }).ToList();
        }