Exemplo n.º 1
0
        /// <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);
            }
        }