Ejemplo n.º 1
0
    public HttpResponseMessage Post(HttpRequestMessage message)
    {
      // Record the message and inform the user.
      //
      MessageRepository rep = new MessageRepository();

      var content = message.Content.ReadAsStringAsync().Result;

      rep.SaveMessage(new Shadow.UShadow.Data.Message() { Body = content });

      return new HttpResponseMessage(HttpStatusCode.OK);
    }
Ejemplo n.º 2
0
    public HttpResponseMessage Get()
    {
      MessageRepository rep = new MessageRepository();
      List<UShadow.Models.Message> messages = new List<Models.Message>();

      foreach (var message in rep.Get())
      {
        messages.Add(new Models.Message() { Body = message.Body });
      }

      return new HttpResponseMessage(HttpStatusCode.OK)
      {
        Content = new ObjectContent<ICollection<UShadow.Models.Message>>(messages, new JsonMediaTypeFormatter())
      };
    }