예제 #1
0
 IList <ContentItem> IContentRepository.GetContentItems(string type)
 {
     using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
     {
         return(GetContentItemsByType(dc, type, _contentCreator).ToList());
     }
 }
예제 #2
0
        ContentItem IContentRepository.GetContentItem(string type, string name, Guid?verticalId, bool includeDisabled)
        {
            var args = new ContentItemQueryArgs {
                Type = type, Name = name, VerticalId = verticalId, IncludeDisabled = includeDisabled
            };

            using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
            {
                // Only certain combinations are supported for now (and they have to be exact).

                if (verticalId != null)
                {
                    if (name != null)
                    {
                        return(GetContentItemByNameAndVertical(dc, args, _contentCreator));
                    }

                    // Just use the type.

                    return(GetContentItemByVertical(dc, args, _contentCreator));
                }

                // Otherwise look for default content.

                if (name != null)
                {
                    return(GetContentItemByName(dc, args, _contentCreator));
                }

                // Everything else.

                return(null);
            }
        }
예제 #3
0
 void IContentRepository.CreateContentItem(ContentItem item)
 {
     using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
     {
         dc.ContentItemEntities.InsertOnSubmit(item.Map());
         dc.SubmitChanges();
     }
 }
예제 #4
0
 private static void DeleteProperties(ContentDataContext dc, ContentItemEntity entity)
 {
     foreach (var childEntity in entity.ContentItemEntities)
     {
         DeleteProperties(dc, childEntity);
     }
     dc.ContentItemEntities.DeleteAllOnSubmit(entity.ContentItemEntities);
     dc.ContentDetailEntities.DeleteAllOnSubmit(entity.ContentDetailEntities);
 }
예제 #5
0
 IList <ContentItem> IContentRepository.GetContentItems(Guid?verticalId)
 {
     using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
     {
         return(verticalId == null
             ? GetDefaultContentItems(dc, _contentCreator).ToList()
             : GetVerticalContentItems(dc, verticalId.Value, _contentCreator).ToList());
     }
 }
예제 #6
0
 void IContentRepository.DeleteContentItem(Guid id)
 {
     using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
     {
         var entity = new ContentItemEntity {
             id = id, deleted = false
         };
         dc.ContentItemEntities.Attach(entity);
         entity.deleted = true;
         dc.SubmitChanges();
     }
 }
예제 #7
0
        void IContentRepository.UpdateContentItem(ContentItem item)
        {
            using (var dc = new ContentDataContext(_connectionFactory.CreateConnection()))
            {
                var entity = GetContentItemEntity(dc, item.Id);
                if (entity != null)
                {
                    // Remove everything on the current entity because it will be replaced.

                    DeleteProperties(dc, entity);

                    item.MapTo(entity);
                    dc.SubmitChanges();
                }
            }
        }