IList <ContentItem> IContentRepository.GetContentItems(string type) { using (var dc = new ContentDataContext(_connectionFactory.CreateConnection())) { return(GetContentItemsByType(dc, type, _contentCreator).ToList()); } }
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); } }
void IContentRepository.CreateContentItem(ContentItem item) { using (var dc = new ContentDataContext(_connectionFactory.CreateConnection())) { dc.ContentItemEntities.InsertOnSubmit(item.Map()); dc.SubmitChanges(); } }
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); }
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()); } }
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(); } }
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(); } } }