Ejemplo n.º 1
0
        public override void Execute(CreateForumCommand command)
        {
            // Nothing special to do here, permissions have been checked and parameters validated!
            IForumDto forum = null;

            if (String.IsNullOrWhiteSpace(command.ParentForumId))
            {
                ICategoryDto category = this.categories.ReadById(command.CategoryId);
                if (category == null)
                {
                    // TODO:
                    throw new ArgumentException("Given category not found");
                }
                forum = this.forums.Create(new Forum(new Category(category), command.Name, command.SortOrder, command.Description));
            }
            else
            {
                IForumDto parentForum = this.forums.ReadById(command.ParentForumId);
                if (parentForum == null)
                {
                    // TODO:
                    throw new ArgumentException("Given forum not found");
                }
                forum = this.forums.CreateAsForumChild(new Forum(new Forum(parentForum), command.Name, command.SortOrder, command.Description));
            }

            this.SetTaskStatus(command.TaskId, forum.Id, "Forum");
        }
Ejemplo n.º 2
0
 public Forum(IForumDto data) : base(data)
 {
     this.Category      = data.Category;
     this.CategoryId    = data.Category.Id;
     this.ParentForum   = data.ParentForum;
     this.ParentForumId = data.ParentForum.Id;
 }
Ejemplo n.º 3
0
        public ReadBreadcrumbForForum Handle(ReadBreadcrumbForForumQuery query)
        {
            IForumDto forum = this.forumDatastore.ReadById(query.ForumId);

            ICategoryDto category = this.categoryDatastore.ReadById(forum.Category.Id);

            IEnumerable <IForumDto> forums = this.forumDatastore.ReadByPath(forum.Path);

            return(new ReadBreadcrumbForForum {
                Category = category,
                Forums = forums
            });
        }
Ejemplo n.º 4
0
        public override void Execute(MoveTopicCommand command)
        {
            // Nothing special to do here, permissions have been checked and parameters validated!
            ITopicDto topic = this.topics.ReadById(command.TopicId);

            if (topic == null)
            {
                // TODO:
                throw new ArgumentNullException("TopicId");
            }
            IForumDto forum = this.forums.ReadById(command.DestinationForumId);

            if (forum == null)
            {
                // TODO:
                throw new ArgumentNullException("ForumId");
            }
            // Moving to another forum?
            if (topic.Forum.Id != forum.Id)
            {
                // Create a new topic or move the old one?
                if (command.CreateMovedTopic)
                {
                    CreateTopicCommand ctc = new CreateTopicCommand {
                        Content = topic.Content,
                        ForumId = forum.Id,
                        State   = topic.State,
                        Subject = topic.Subject,
                        Type    = topic.Type
                    };
                    this.commandDispatcher.Dispatch <CreateTopicCommand>(ctc);

                    // TODO:
                    String newTopicId = this.taskDatastore.GetTaskStatus(ctc.TaskId).Item1;

                    this.commandDispatcher.Dispatch <MergeTopicsCommand>(new MergeTopicsCommand {
                        CreateReplyForTopics = false,
                        SourceTopicIds       = new String[] { topic.Id },
                        DestinationTopicId   = newTopicId
                    });

                    // TODO: Change Type on original topic !!!!!
                }
                else
                {
                    this.topics.Move(topic.Id, forum.Id);
                }
            }

            this.SetTaskStatus(command.TaskId, command.TopicId, "Topic");
        }
Ejemplo n.º 5
0
        public override void Execute(CreateTopicCommand command)
        {
            // Nothing special to do here, permissions have been checked and parameters validated!
            IForumDto forum = this.forums.ReadById(command.ForumId);

            if (forum == null)
            {
                // TODO:
                throw new ArgumentException("Parent forum not found!");
            }

            Topic     t        = new Topic(new Forum(forum), command.Subject, command.Content, command.Type, command.State);
            ITopicDto newTopic = this.topics.Create(t);

            this.SetTaskStatus(command.TaskId, newTopic.Id, "Topic");
        }
Ejemplo n.º 6
0
        public override void Execute(UpdateForumCommand command)
        {
            // Permissions have been checked and parameters validated!
            IForumDto dto = this.forums.ReadById(command.Id);

            if (dto == null)
            {
                throw new ForumNotFoundException(command.Id);
            }

            Forum f = new Forum(dto);

            f.Name        = command.Name;
            f.SortOrder   = command.SortOrder;
            f.Description = command.Description;
            f.ClearAndAddProperties(f.Properties);

            this.forums.Update(f);

            this.SetTaskStatus(command.TaskId, command.Id, "Forum");
        }
Ejemplo n.º 7
0
 public static Forum ToDomainObject(this IForumDto dto)
 {
     return(new Forum(dto));
 }