示例#1
0
 public void Delete(Topic topic)
 {
     foreach (Message message in topic.Messages)
     {
         Provider.DeleteListItem(ForumConstants.Lists_Posts, message.Id);
     }
     Provider.DeleteListItem(ForumConstants.Lists_Topics, topic.Id);
 }
示例#2
0
        public static SharePointListItem CreateDto(Topic topic)
        {
            string[] topicValues = {
				"Title", topic.Name,
				"ForumID", topic.ForumId.ToString(),
				"Views", topic.Views.ToString(),
				"TopicStarterID", topic.TopicStarterId.ToString(),
			};

            return new SharePointListItem(topic.Id, topicValues);
        }
示例#3
0
        public static Topic CreateDomainObject(SharePointListItem item)
        {
            Topic topic = new Topic(item.Id, Convert.ToInt32(item["ForumID"]), item["Title"]);

            topic.Views = Convert.ToInt32(item["Views"]);
            topic.TopicStarterId = Convert.ToInt32(item["TopicStarterID"]);
            topic.Author = RepositoryRegistry.ForumUserRepository.GetBySharePointId(topic.TopicStarterId);

            // Built in values from SharePoint list
            // TODO might be the wrong value
            topic.LastPost = Convert.ToDateTime(item["Modified"]);

            return topic;
        }
示例#4
0
        public int Save(Topic topic)
        {
            SharePointListItem listItem = TopicMapper.CreateDto(topic);
            int newTopicId = 0;

            if (topic.Id == 0)
            {
                newTopicId = Provider.AddListItem(ForumConstants.Lists_Topics, listItem);
                RepositoryRegistry.ForumRepository.IncreaseCount(topic.ForumId);
            }
            else
            {
                newTopicId = Provider.UpdateListItem(ForumConstants.Lists_Topics, listItem);
            }

            return newTopicId;
        }
示例#5
0
 public void Delete(Topic topic)
 {
     _dao.Delete(topic);
 }
示例#6
0
 public int Save(Topic topic)
 {
     return _dao.Save(topic);
 }
示例#7
0
 /// <summary>
 /// Setups the default values.
 /// </summary>
 public override void AddSampleData()
 {
     Topic topic = new Topic(1, "Welcome to your new SharePoint Forum");
     topic.TopicStarterId = 1;
     RepositoryRegistry.TopicRepository.Save(topic);
 }