Example #1
0
        public IReplyDto Create(Domain.Reply reply)
        {
            Dbos.Topic topic = this.datastore.ReadTopicById(ObjectId.Parse(reply.TopicId));
            if (topic == null)
            {
                // TODO ??
                throw new ArgumentException("Parent topic not found");
            }

            Dbos.Reply r = new Dbos.Reply {
                Content = reply.Content,
                Created = reply.Created,
                //CreatedBy =
                LastEdited = reply.LastEdited,
                //LastEditedBy =
                State   = reply.State,
                Subject = reply.Subject,
                Topic   = new TopicRef {
                    Id      = ObjectId.Parse(reply.Topic.Id),
                    Subject = reply.Topic.Subject
                }
            };

            if (!String.IsNullOrWhiteSpace(reply.ReplyToId))
            {
                Dbos.Reply parentReply = this.datastore.ReadReplyById(ObjectId.Parse(reply.ReplyToId));
                if (parentReply == null)
                {
                    // TODO ??
                    throw new ArgumentException("Parent reply not found");
                }

                r.ReplyTo = new Dbos.ReplyRef {
                    Id   = parentReply.Id,
                    Name = parentReply.Subject
                };
            }

            return(this.datastore.CreateReply(r).ToDto());
        }
Example #2
0
 public virtual Dbos.Reply CreateReply(Dbos.Reply reply)
 {
     this.replies.InsertOne(reply);
     return(reply);
 }