Exemplo n.º 1
0
        // convert CreaeteRequestMessage Object to Message
        public static Message toMessage(CreateRequestMessage message)
        {
            Message m = new Message();

            m.from    = message.from;
            m.to      = message.to;
            m.date    = message.date;
            m.message = message.message;

            return(m);
        }
        //
        // Create a message
        //
        public CreateResponseMessage createMessage(CreateRequestMessage msg)
        {
            CreateResponseMessage response;
            Message      message = MessageMapper.toMessage(msg);
            BsonDocument doc     = MessageMapper.toBsonDocument(message);

            try
            {
                col.InsertOne(doc);
                message.id = doc["_id"].ToString();
                response   = new CreateResponseMessage(Status.STATUS.SUCCESS, msg, message, null);
            }
            catch (MongoWriteException err)
            {
                response = new CreateResponseMessage(Status.STATUS.ERROR, msg, message, err);
            }

            return(response);
        }
Exemplo n.º 3
0
 public CreateResponseMessage(Enum status, CreateRequestMessage req, Message message, Object mongoResult)
 {
     this.message = message;
     this.request = req;
     this.result  = new Result(Status.OPERATION.CREATE, status, 1, mongoResult);
 }
Exemplo n.º 4
0
        //
        // Create a message
        //
        public CreateResponseMessage createMessage(CreateRequestMessage req)
        {
            CreateResponseMessage response = messageDao.createMessage(req);

            return(response);
        }
 public ActionResult <CreateResponseMessage> Post([FromBody] CreateRequestMessage req)
 {
     return(service.createMessage(req));
 }