Ejemplo n.º 1
0
 private static ContentTypeItem CreateContentTypeItem(ContentType contentType)
 {
     var contentTypeItem = new ContentTypeItem { Type = contentType.Type, DisplayName = contentType.DisplayName, ControllerName = contentType.ControllerName };
     var contentActionItems =
         contentType.Actions.Select(
             action => new ContentActionItem { Action = action.Action, ContentType = contentType.Type, DisplayName = action.DisplayName });
     contentTypeItem.ContentActionItems.AddRange(contentActionItems);
     return contentTypeItem;
 }
Ejemplo n.º 2
0
        private static void UpdateContentTypeItem(ContentTypeItem contentTypeItem, ContentType contentType, ContentDataContext contentDataContext)
        {
            contentTypeItem.DisplayName = contentType.DisplayName;

            var actionsToDelete = (from item in contentTypeItem.ContentActionItems
                                   where !contentType.Actions.Any(action => action.Action == item.Action)
                                   select item).ToList();

            var actionsToUpdate = (from item in contentTypeItem.ContentActionItems
                                   let action = contentType.Actions.SingleOrDefault(a => a.Action == item.Action)
                                   where action != null
                                   select new { item, action }).ToList();

            var actionsToInsert = (from action in contentType.Actions
                                   where !contentTypeItem.ContentActionItems.Any(a => a.Action == action.Action)
                                   select new ContentActionItem { Action = action.Action, ContentType = contentTypeItem.Type, DisplayName = action.DisplayName }).
                ToList();

            contentDataContext.ContentActionItems.DeleteAllOnSubmit(actionsToDelete);
            actionsToUpdate.ForEach(a => { a.item.DisplayName = a.action.DisplayName; });
            contentTypeItem.ContentActionItems.AddRange(actionsToInsert);
        }
Ejemplo n.º 3
0
 partial void UpdateContentTypeItem(ContentTypeItem instance);
Ejemplo n.º 4
0
 partial void DeleteContentTypeItem(ContentTypeItem instance);
Ejemplo n.º 5
0
 partial void InsertContentTypeItem(ContentTypeItem instance);