// GET api/messagebody/5
        public HttpResponseMessage Get(string id)
        {
            MessageApiBaseModel<MessageBodyResponseModel> model = new MessageApiBaseModel<MessageBodyResponseModel>();

            MessageBodyResponseModel response = new MessageBodyResponseModel();
            response.messageId = Guid.Parse(id);
            response.body = "<HTML><BODY>Hello World!</BODY></HTML>";

            List<MessageBodyResponseModel> list = new List<MessageBodyResponseModel>();

            list.Add(response);

            model.results = list;
            model.count = list.Count;

            string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(model);

            var resp = new HttpResponseMessage()
            {
                Content = new StringContent(serialized)
            };

            resp.Content.Headers.ContentType =
                          new MediaTypeHeaderValue("application/json");

            return resp;
        }
Exemplo n.º 2
0
        // GET api/message/5
        public HttpResponseMessage Get(string id)
        {
            MessageApiBaseModel<MessageListResponseModel> model = new MessageApiBaseModel<MessageListResponseModel>();

            MessageListResponseModel response = null;

            List<MessageListResponseModel> list = new List<MessageListResponseModel>();

            response = new MessageListResponseModel();

            response.expires = DateTime.Now.AddDays(2);
            response.lastUpdate = DateTime.Now.AddDays(-1);
            response.messageId = Guid.NewGuid();
            response.messageScheduleId = Guid.NewGuid();
            response.subject = "I've got something in my pocket for you...";

            list.Add(response);

            response = new MessageListResponseModel();

            response.expires = DateTime.Now.AddDays(3);
            response.lastUpdate = DateTime.Now.AddDays(-2);
            response.messageId = Guid.NewGuid();
            response.messageScheduleId = Guid.NewGuid();
            response.subject = "Why HELLLOOOOOO there!";

            list.Add(response);

            model.results = list;
            model.count = list.Count;

            string serialized = Newtonsoft.Json.JsonConvert.SerializeObject(model);

            var resp = new HttpResponseMessage()
            {
                Content = new StringContent(serialized)
            };

            resp.Content.Headers.ContentType =
                          new MediaTypeHeaderValue("application/json");

            return resp;
        }