/// <summary> /// Creates list list item for given list /// </summary> /// <param name="listItemId">list item id</param> /// <param name="parentListId">list id</param> /// <param name="title">list item title</param> /// <param name="content">list item content</param> public void CreateListItem(Guid listItemId, Guid parentListId, string title, string content) { ListsManager listManager = ListsManager.GetManager(); List parent = listManager.GetLists().Where(l => l.Id == parentListId).FirstOrDefault(); if (parent != null) { ListItem listItem = listManager.CreateListItem(listItemId); listItem.Parent = parent; listItem.Title = title; listItem.Content = content; listItem.UrlName = Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-"); listItem.DateCreated = DateTime.Now; listManager.RecompileAndValidateUrls(listItem); listManager.SaveChanges(); var bag = new Dictionary <string, string>(); bag.Add("ContentType", typeof(ListItem).FullName); WorkflowManager.MessageWorkflow(listItemId, typeof(ListItem), null, "Publish", false, bag); } }
/// <summary> /// Deletes list by given id /// </summary> /// <param name="listId">list id</param> public void DeleteList(Guid listId) { ListsManager listsManager = ListsManager.GetManager(); List list = listsManager.GetLists().Where(l => l.Id == listId).FirstOrDefault(); if (list != null) { listsManager.DeleteList(list); listsManager.SaveChanges(); } }