ContentExtension.cs :  » Content-Management-Systems-CMS » Kooboo » Everest » CmsServices » MvcHelper » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » Kooboo 
Kooboo » Everest » CmsServices » MvcHelper » ContentExtension.cs
/*
Kooboo is a content management system based on ASP.NET MVC framework. Copyright 2009 Yardi Technology Limited.

This program is free software: you can redistribute it and/or modify it under the terms of the
GNU General Public License version 3 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program.
If not, see http://www.kooboo.com/gpl3/.
*/
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using Everest.CmsServices.Models;

namespace Everest.CmsServices.MvcHelper{
    public static class ContentExtension
    {
        private static CmsContext CmsContext
        {
            get
            {
                return HttpContext.Current.GetCmsContext();
            }
        }

        #region DataTypeConvertor
        /// <summary>
        /// Toes the list.
        /// </summary>
        /// <param name="contents">The contents.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> ToList(object contents)
        {
            return (IEnumerable<IDictionary<string, object>>)contents;
        }
        /// <summary>
        /// Toes the content.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <returns></returns>
        public static IDictionary<string, object> ToContent(object content)
        {
            return (IDictionary<string, object>)content;
        }
        #endregion

        #region Get SubContent
        /// <summary>
        /// Gets the sub contents.
        /// </summary>
        /// <param name="parentContent">Content of the parent.</param>
        /// <param name="schemaName">Name of the schema of subcontent.</param>
        ///  <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="orderBy">The order by field. For example: Title DESC</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="startIndex">The start index.starts from 1</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetSubContents(this IDictionary<string, object> parentContent, string schemaName
            , string queryStatement, string orderBy, NameValueCollection queryValues, int startIndex, int pageSize, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)parentContent["UUID"];
            return CmsContext.ContentService.GetSubContents(contentUUID, schemaName, queryStatement, orderBy, queryValues, startIndex, pageSize, cacheTime);
        }
        /// <summary>
        /// Gets the sub contents.
        /// </summary>
        /// <param name="parentContent">Content of the parent.</param>
        /// <param name="schemaName">Name of the schema of subcontent.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetSubContents(this IDictionary<string, object> parentContent, string schemaName)
        {
            var contentUUID = (Guid)parentContent["UUID"];
            return CmsContext.ContentService.GetSubContents(contentUUID, schemaName);
        }

        /// <summary>
        /// Gets the sub content count.
        /// </summary>
        /// <param name="parentContent">Content of the parent.</param>
        /// <param name="schemaName">Name of the schema of subcontent.</param>
        ///  <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static int GetSubContentCount(this IDictionary<string, object> parentContent, string schemaName, string queryStatement, NameValueCollection queryValues, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)parentContent["UUID"];
            return CmsContext.ContentService.GetSubContentCount(contentUUID, schemaName, queryStatement, queryValues, null);

        }
        /// <summary>
        /// Gets the sub content count.
        /// </summary>
        /// <param name="parentContent">Content of the parent.</param>
        /// <param name="schemaName">Name of the schema of subcontent.</param>
        /// <returns></returns>
        public static int GetSubContentCount(this IDictionary<string, object> parentContent, string schemaName)
        {
            var contentUUID = (Guid)parentContent["UUID"];
            return CmsContext.ContentService.GetSubContentCount(contentUUID, schemaName);

        }
        #endregion

        #region Content data extension
        #region GetContentsByCategory
        /// <summary>
        /// Gets the contents by category and schema.
        /// </summary>
        /// <param name="category">The content of category.</param>
        /// <param name="schemaName">The content schema to be returnd. Not the category schema</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="orderBy">The order by field. For example: Title DESC</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="startIndex">The start index.starts from 1</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetContentsByCategoryAndSchema(this IDictionary<string, object> category
            , string schemaName, string queryStatement, string orderBy, NameValueCollection queryValues, int startIndex, int pageSize
            , TimeSpan? cacheTime)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentsByCategoryAndSchema(categoryOriginalUUID, schemaName
                , queryStatement, orderBy, queryValues, startIndex, pageSize, cacheTime);
        }

        /// <summary>
        /// Gets the content count by category and schema.
        /// </summary>
        /// <param name="category">The content of category.</param>
        /// <param name="schemaName">The content schema to be returnd. Not the category schema</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static int GetContentCountByCategoryAndSchema(this IDictionary<string, object> category, string schemaName, string queryStatement
            , NameValueCollection queryValues, TimeSpan? cacheTime)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentCountByCategoryAndSchema(categoryOriginalUUID, schemaName, queryStatement, queryValues, cacheTime);
        }

        /// <summary>
        /// Gets the contents by category and folder.
        /// </summary>
        /// <param name="category">The  content of category.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="orderBy">The order by field. For example: Title DESC</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="startIndex">The start index. starts from 1</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetContentsByCategoryAndFolder(this IDictionary<string, object> category, string folderName,
          string queryStatement, string orderBy, NameValueCollection queryValues, int startIndex, int pageSize, TimeSpan? cacheTime)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentsByCategoryAndFolder(categoryOriginalUUID, folderName
                , queryStatement, orderBy, queryValues, startIndex, pageSize, cacheTime);
        }
        /// <summary>
        /// Gets the contents by category and folder.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetContentsByCategoryAndFolder(this IDictionary<string, object> category, string folderName)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentsByCategoryAndFolder(categoryOriginalUUID, folderName);
        }

        /// <summary>
        /// Gets the content count by category and folder.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static int GetContentCountByCategoryAndFolder(this IDictionary<string, object> category, string folderName, string queryStatement,
           NameValueCollection queryValues, TimeSpan? cacheTime)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentCountByCategoryAndFolder(categoryOriginalUUID, folderName,
                queryStatement, queryValues, cacheTime);
        }
        /// <summary>
        /// Gets the content count by category and folder.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns></returns>
        public static int GetContentCountByCategoryAndFolder(this IDictionary<string, object> category, string folderName)
        {
            var categoryOriginalUUID = (Guid)category["OriginalUUID"];
            return CmsContext.ContentService.GetContentCountByCategoryAndFolder(categoryOriginalUUID, folderName);
        }

        #endregion

        #region GetCategoriesByContent
        /// <summary>
        /// Gets the categories by content and schema.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="schemaName">The cateogry schema of object returned.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="orderBy">The order by field. For example: Title DESC</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="startIndex">The start index.starts from 1</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetCategoriesByContentAndSchema(this IDictionary<string, object> content, string schemaName,
            string queryStatement, string orderBy, NameValueCollection queryValues, int startIndex, int pageSize, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoriesByContentAndSchema(contentUUID, schemaName, queryStatement, orderBy,
                queryValues, startIndex, pageSize, cacheTime);
        }

        /// <summary>
        /// Gets the categories by content and schema.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetCategoriesByContentAndSchema(this IDictionary<string, object> content, string schemaName)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoriesByContentAndSchema(contentUUID, schemaName);
        }

        /// <summary>
        /// Gets the category count by content and schema.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="schemaName">The cateogry schema of object returned.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static int GetCategoryCountByContentAndSchema(this IDictionary<string, object> content, string schemaName, string queryStatement,
            NameValueCollection queryValues, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoryCountByContentAndSchema(contentUUID, schemaName, queryStatement, queryValues, cacheTime);
        }


        /// <summary>
        /// Gets the category count by content and schema.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <returns></returns>
        public static int GetCategoryCountByContentAndSchema(this IDictionary<string, object> content, string schemaName)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoryCountByContentAndSchema(contentUUID, schemaName);
        }

        /// <summary>
        /// Gets the categories by content and folder.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="folderName">Name of the folder of category content.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="orderBy">The order by field. For example: Title DESC</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <param name="startIndex">The start index.starts from 1</param>
        /// <param name="pageSize">Size of the page.</param>
        /// <param name="cacheTime">The cache time.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetCategoriesByContentAndFolder(this IDictionary<string, object> content, string folderName,
          string queryStatement, string orderBy, NameValueCollection queryValues, int startIndex, int pageSize, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoriesByContentAndFolder(contentUUID, folderName, queryStatement,
                orderBy, queryValues, startIndex, pageSize, cacheTime);
        }
        /// <summary>
        /// Gets the categories by content and folder.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns></returns>
        public static IEnumerable<IDictionary<string, object>> GetCategoriesByContentAndFolder(this IDictionary<string, object> content, string folderName)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoriesByContentAndFolder(contentUUID, folderName);
        }
        /// <summary>
        /// Gets the category count by content and folder.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="folderName">Name of the folder of category content.</param>
        /// <param name="queryStatement">The query statement.For example: Title={Title}</param>
        /// <param name="queryValues">The query values. The values for Query Statment parameters</param>
        /// <returns></returns>
        public static int GetCategoryCountByContentAndFolder(this IDictionary<string, object> content, string folderName, string queryStatement,
           NameValueCollection queryValues, TimeSpan? cacheTime)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoryCountByContentAndFolder(contentUUID, folderName, queryStatement, queryValues, cacheTime);
        }

        /// <summary>
        /// Gets the category count by content and folder.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns></returns>
        public static int GetCategoryCountByContentAndFolder(this IDictionary<string, object> content, string folderName)
        {
            var contentUUID = (Guid)content["UUID"];
            return CmsContext.ContentService.GetCategoryCountByContentAndFolder(contentUUID, folderName);
        } 
        #endregion
        #endregion
    }
}

www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.