/// <summary>
        /// Returns a content ID for a particular request
        /// </summary>
        /// <param name="request">the incoming request</param>
        /// <param name="host">the host for this request (i.e. "localhost")</param>
        /// <returns>a nullable content ID for the content if available</returns>
        public Guid?GetIDByPrimaryUrl(string request, string host)
        {
            Guid?contentID = null;

            using (SqlConnection conn = (SqlConnection)_factory.GetConnection())
            {
                SqlCommand comm = (SqlCommand)_factory.GetCommand("GetContentIDByPrimaryURL");
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.AddWithValue("@url", request);
                comm.Parameters.AddWithValue("@host", host);

                try
                {
                    conn.Open();
                    SqlDataReader reader = comm.ExecuteReader();
                    if (reader.Read())
                    {
                        contentID = (Guid)reader[0];
                    }
                }
                finally
                {
                    conn.Close();
                }
            }

            return(contentID);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new site in the CMS.
        /// </summary>
        /// <param name="title">the title of the site</param>
        /// <param name="domain">the domain entry for the site</param>
        public void CreateSite(string title, string domain)
        {
            using (SqlConnection conn = (SqlConnection)_factory.GetConnection())
            {
                SqlCommand comm = (SqlCommand)_factory.GetCommand("CreateSite");
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.AddWithValue("@title", title);
                comm.Parameters.AddWithValue("@host", domain);

                try
                {
                    conn.Open();
                    comm.ExecuteNonQuery();
                }
                finally
                {
                    conn.Close();
                }
            }
        }
        /// <summary>
        /// Loads the data for a single piece of content.
        /// </summary>
        /// <param name="contentID">the ID of the content to load</param>
        /// <returns>an object that implements IContentEntity</returns>
        public IContentEntity GetContentEntity(Guid contentID)
        {
            IContentEntity entity = new ContentEntity();

            using (SqlConnection conn = (SqlConnection)_factory.GetConnection())
            {
                SqlCommand comm = (SqlCommand)_factory.GetCommand("GetContentEntity");
                comm.CommandType = CommandType.StoredProcedure;
                comm.Parameters.AddWithValue("@contentID", contentID);

                try
                {
                    conn.Open();
                    var reader = comm.ExecuteReader();
                    while (reader.Read())
                    {
                        entity.ContentID = contentID;
                        if (!reader.IsDBNull(1))
                        {
                            entity.Title = reader.GetString(1);
                        }
                        if (!reader.IsDBNull(2))
                        {
                            entity.ParentID = reader.GetGuid(2);
                        }
                        if (!reader.IsDBNull(3))
                        {
                            entity.SiteID = reader.GetInt32(3);
                        }
                        if (!reader.IsDBNull(4))
                        {
                            entity.Author = reader.GetString(4);
                        }
                        if (!reader.IsDBNull(5))
                        {
                            entity.FriendlyUrl = reader.GetString(5);
                        }
                        if (!reader.IsDBNull(6))
                        {
                            entity.CurrentRevision = reader.GetGuid(6);
                        }
                        if (!reader.IsDBNull(7))
                        {
                            entity.Keywords = reader.GetString(7);
                        }
                        if (!reader.IsDBNull(8))
                        {
                            entity.Description = reader.GetString(8);
                        }
                        if (!reader.IsDBNull(9))
                        {
                            entity.Visible = reader.GetBoolean(9);
                        }
                        if (!reader.IsDBNull(10))
                        {
                            entity.FollowLinks = reader.GetBoolean(10);
                        }
                    }
                }
                finally
                {
                    conn.Close();
                }
            }
            return(entity);
        }