Пример #1
0
 private static List<CMSMenuItem> MapProductsForCategory(List<tbl_Products> products, CustomPrincipal currentUser)
 {
     return products.OrderBy(p => p.P_Order).Select(product => new CMSMenuItem
     {
         MenuItemID = product.ProductID,
         Title = String.Format("{0} ({1})", product.P_Title, product.P_ProductCode),
         DeleteText = String.Format("Delete {0} ({1})", product.P_Title, product.ProductID),
         EditText = String.Format("Edit {0}", product.P_Title),
         IsEditImages = true,
         EditImagesText = "Images",
         IsAssociation = true,
         IsMove = true,
         IsApprove = product.tbl_SiteMap.tbl_Content.Where(c => !c.C_Deleted).All(c => !c.C_Approved) &&
                 currentUser.HasPermission(Permission.ApproveContent),
         ApproveText = "Content Requires Approval",
         IsStock = true,
         StockText = "Stock"
     }).ToList();
 }
Пример #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();
        }
Пример #3
0
 public static List<CMSMenuModel> MapUsers(List<tbl_AdminUsers> users, CustomPrincipal currentUser)
 {
     return new List<CMSMenuModel>
     {
         new CMSMenuModel
         {
             Title = "Users",
             MenuItems = users.Select(user => new CMSMenuItem
                 {
                     MenuItemID = user.AdminUserID,
                     Title = String.Format("<b>{0}: {1}</b> ({2})", user.US_UserName, user.US_Email, user.tbl_UserGroups.UG_Type),
                     IsDelete = currentUser.HasPermission(Permission.DeleteUser),
                     IsEdit = currentUser.HasPermission(Permission.EditUser)
                 }).ToList()
             }
     };
 }
Пример #4
0
 private static List<CMSMenuItem> CreateProdSubCategories(List<tbl_SiteMap> categories, int parentID, CustomPrincipal currentUser)
 {
     return categories.Where(c => c.tbl_ProdCategories.PC_ParentID.GetValueOrDefault(0) == parentID)
         .Select(category => new CMSMenuItem
         {
             MenuItemID = category.tbl_ProdCategories.CategoryID,
             Title = category.tbl_ProdCategories.PC_Title,
             SubMenuItems = CreateProdSubCategories(categories, category.SiteMapID, currentUser),
             DeleteText = String.Format("Delete {0} ({1})", category.tbl_ProdCategories.PC_Title, category.tbl_ProdCategories.CategoryID),
             EditText = String.Format("Edit {0}", category.tbl_ProdCategories.PC_Title),
             IsEditImages = true,
             EditImagesText = "Image",
             IsMove = true,
             IsApprove = category.tbl_Content.Where(c => !c.C_Deleted).All(c => !c.C_Approved) && currentUser.HasPermission(Permission.ApproveContent),
             ApproveText = String.Format("{0} Category Requires Approval", category.tbl_ProdCategories.PC_Title),
         }).ToList();
 }
Пример #5
0
 public static List<CMSMenuModel> MapNews(List<tbl_Domains> domains, CustomPrincipal currentUser)
 {
     return domains.Select(domain => new CMSMenuModel
         {
             Title = "Blog Articles for " + domain.DO_CompanyName,
             MenuItems = domain.tbl_SiteMap
             .Where(sm => !sm.SM_Deleted && sm.IsType(ContentType.Blog)).OrderByDescending(b => b.SM_Live).ThenByDescending(b => b.SM_Date)
             .Select(b => new CMSMenuItem
                 {
                     MenuItemID = b.SiteMapID,
                     Date = b.SM_Date,
                     IsFuturePublish = b.SM_PublishDate == null ? false : (b.SM_PublishDate >= DateTime.Now),
                     PublishDateText = b.SM_PublishDate != null ? ("Publish date: " + b.SM_PublishDate.ToString()) : String.Empty,
                     Title = b.SM_Name,
                     IsDelete = currentUser.HasPermission(Permission.DeleteNews),
                     DeleteText = String.Format("Delete {0} ({1})", b.SM_Name, b.SiteMapID),
                     IsEdit = currentUser.HasPermission(Permission.EditNews),
                     EditText = String.Format("Edit \"{0}\"", b.SM_Name),
                     IsEditImages = currentUser.HasPermission(Permission.EditNews),
                     EditImagesText = String.Format("Edit images for \"{0}\"", b.SM_Name),
                     IsComment = true,
                     CommentsText = String.Format("View comments for \"{0}\"", b.SM_Name),
                     UnauthorizedCommentExists = b.tbl_Comments.Any(c => !c.CO_Authorised),
                     AuthorizedCommentExists = b.tbl_Comments.Any(c => c.CO_Authorised),
                     IsVisibility = true,
                     VisibilityText = "Turn news article on / off",
                     Visible = b.SM_Live
                 }).ToList()
         }).ToList();
 }