Esempio n. 1
0
 public Reply(IReplyDto data) : base(data)
 {
     this.Topic     = data.Topic;
     this.TopicId   = data.Topic.Id;
     this.ReplyTo   = data.ReplyTo;
     this.ReplyToId = data.ReplyTo.Id;
 }
        public override void Execute(CreateReplyCommand command)
        {
            // Nothing special to do here, permissions have been checked and parameters validated!
            ITopicDto topic = null;
            IReplyDto reply = null;

            if (!String.IsNullOrWhiteSpace(command.ParentReplyId))
            {
                reply = this.replies.ReadById(command.ParentReplyId);
                if (reply == null)
                {
                    // TODO:
                    throw new ArgumentException("Parent reply not found!");
                }
                topic = this.topics.ReadById(reply.Topic.Id);
            }
            else
            {
                topic = this.topics.ReadById(command.TopicId);
            }
            if (topic == null)
            {
                // TODO:
                throw new ArgumentException("Parent topic not found!");
            }

            Reply r = null;

            if (reply != null)
            {
                r = new Reply(new Reply(reply), command.Subject, command.Content, command.State);
            }
            else
            {
                r = new Reply(new Topic(topic), command.Subject, command.Content, command.State);
            }
            this.replies.Create(r);

            this.SetTaskStatus(command.TaskId, r.Id, "Reply");
        }