Example #1
0
        //public HttpResponseMessage Get()
        //{
        //    var resp = new HttpResponseMessage()
        //    {
        //        Content = new StringContent("[{\"Name\":\"ABC\"},[{\"A\":\"1\"},{\"B\":\"2\"},{\"C\":\"3\"}]]")
        //    };
        //    resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
        //    return resp;
        //}
        // POST api/chat
        public HttpResponseMessage Post(MessageDto value)
        {
            if (ModelState.IsValid)
            {
                _dataServiceDto.CreateMessage(value);

                //DataService.CreateMessage(value.ChatUserId, value.MessageText, value.GpsXCoord, value.GpsYCoord);
                //notatweetRepository.InsertOrUpdate(value);
                //notatweetRepository.Save();

                //Created!
                var response = Request.CreateResponse(HttpStatusCode.Created, value);
                //var response = new HttpResponseMessage<NotATweet>(value, HttpStatusCode.Created);

                //Let them know where the new NotATweet is
                string uri = Url.Route(null, new { id = value.ChatUserId });
                response.Headers.Location = new Uri(Request.RequestUri, uri);

                return response;

            }
            throw new HttpResponseException(HttpStatusCode.BadRequest);
        }
Example #2
0
 public void CreateMessage(MessageDto message)
 {
     _dataServiceMessage.CreateMessage(Mapper.Map<MessageDto, Message>(message));
 }
Example #3
0
 // PUT api/chat/5
 public HttpResponseMessage Put(int id, MessageDto value)
 {
     if (ModelState.IsValid)
     {
         //notatweetRepository.InsertOrUpdate(value);
         //notatweetRepository.Save();
         return new HttpResponseMessage(HttpStatusCode.NoContent);
     }
     throw new HttpResponseException(HttpStatusCode.BadRequest);
 }