Ejemplo n.º 1
0
        /// <summary>
        /// Takes a content region key and html to update it with.  This is how the content gets IN.
        /// </summary>
        /// <param name="region"></param>
        /// <param name="html"></param>
        public static void Update(string key, string html)
        {
            using (var ctx = new picoDataContextDataContext(ContentRegion.ConnectionString))
            {
                var content = GetContentRegion(key, ctx);

                if (content == null)
                    ctx.picocms_ContentRegions.InsertOnSubmit(
                        new picocms_ContentRegion()
                        {
                            ContentRegionID = Guid.NewGuid(),
                            Key = key,
                            Text = html
                        });

                else
                    content.Text = html;

                ctx.SubmitChanges();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a content region by its key, tied to the data context provided.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        internal static picocms_ContentRegion GetContentRegion(string key, picoDataContextDataContext ctx)
        {
            if (ctx == null || String.IsNullOrEmpty(key)) return null;

            var query = from cr in ctx.picocms_ContentRegions
                        where cr.Key == key
                        select cr;
            return query.FirstOrDefault();
        }