/// <summary> /// Creates a new wall post /// </summary> /// <param name="web">The current web</param> /// <param name="newEntity">The new wall post entity</param> public void Create(SPWeb web, WallPost newEntity) { // Use SPWebContext so that the repo can be used by code called from outside a web request context (e.g. Powershell or OWSTimer) var list = web.GetList(SPUtility.ConcatUrls(web.ServerRelativeUrl, ListUrls.WallPosts)); var newListItem = list.AddItem(); this._binder.FromEntity(newEntity, newListItem); newListItem.Update(); }
/// <summary> /// Creates a new post on the wall /// </summary> /// <param name="message">Text content of the post</param> /// <returns>The new WallPost object, null if something went wrong</returns> public WallPost AddPost(string message) { WallPost newPost = null; if (!string.IsNullOrEmpty(message)) { newPost = new WallPost(); newPost.Title = message.Length >= 255 ? message.Substring(0, 255) : message; newPost.Text = message; newPost.Author = new UserValue(SPContext.Current.Web.CurrentUser.ID); // Auto-tagging this.AddTags(message, newPost.Tags); this._wallPostRepository.Create(SPContext.Current.Web, newPost); } return newPost; }