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"); }
public Forum(IForumDto data) : base(data) { this.Category = data.Category; this.CategoryId = data.Category.Id; this.ParentForum = data.ParentForum; this.ParentForumId = data.ParentForum.Id; }
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 }); }
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"); }
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"); }
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"); }
public static Forum ToDomainObject(this IForumDto dto) { return(new Forum(dto)); }