示例#1
0
 /// <summary>
 /// Setups the default values.
 /// </summary>
 public override void AddSampleData()
 {
     Message message = new Message(1);
     message.Name = "Welcome to your new SharePoint Forum";
     message.UserId = 1;
     message.Body = "<DIV>This is an example post in your SharePoint Forum installation. You may delete this post, this topic and even this forum if you like since everything seems to be working!</DIV>";
     RepositoryRegistry.MessageRepository.Save(message);
 }
示例#2
0
        public static SharePointListItem CreateDto(Message message)
        {
            string[] postValues = {
				"Title", message.Name,
				"TopicID", message.TopicId.ToString(),
				"Body", message.Body,
				"UserID", message.UserId.ToString(),
			};

            return new SharePointListItem(message.Id, postValues);
        }
示例#3
0
        public static Message CreateDomainObject(SharePointListItem listItem)
        {
            Message message = new Message(Convert.ToInt32(listItem["TopicID"]));

            message.Name = listItem["Title"];
            message.UserId = Convert.ToInt32(listItem["UserID"]);
            message.Author = RepositoryRegistry.ForumUserRepository.GetBySharePointId(message.UserId);
            message.Created = Convert.ToDateTime(listItem["Created"]);
            message.Body = listItem["Body"];
            message.Id = listItem.Id;

            return message;
        }
示例#4
0
 public void Save(Message message)
 {
     SharePointListItem listItem = MessageMapper.CreateDto(message);
     if (message.Id == 0)
     {
         Provider.AddListItem(ForumConstants.Lists_Posts, listItem);
         //				TopicRepository.IncreasePostCount(message.TopicId);
     }
     else
     {
         Provider.UpdateListItem(ForumConstants.Lists_Posts, listItem);
     }
 }
示例#5
0
        public IList<Message> FindByKeywords(string keywords)
        {
            // TODO this is broken and needs to use CAML instead
            IList<Message> messages = new List<Message>();
            if (keywords == null)
                return messages;

            SPSearchResultCollection searchResults = ForumApplication.Instance.SpWeb.SearchListItems(keywords);
            foreach (SPSearchResult result in searchResults)
            {
                if (result.ListName.ToUpper() == ForumConstants.Lists_Posts.ToUpper())
                {
                    Message message = new Message(0);
                    message.Name = result.Title;
                    messages.Add(message);
                }
            }

            return messages;
        }
示例#6
0
 public void Save(Message message)
 {
     _dao.Save(message);
 }