Beispiel #1
0
        public HttpResponseMessage  AddChat([FromUri()] string username, [FromUri()] string text,
                                            [FromUri()] int timeout)
        {
            try
            {
                var crud = new AwsController();
                var chat = new Chat
                {
                    text     = text,
                    username = username,
                    timeout  = timeout
                };

                var id = crud.CreateChatItem(chat);
                if (id > 0)
                {
                    var jsonObject = new JObject();
                    jsonObject.Add("id", id);

                    return(Request.CreateResponse(HttpStatusCode.Created, jsonObject));
                }
                else
                {
                    return(Request.CreateResponse("Something went wrong"));
                }
            }
            catch
            {
                return(Request.CreateResponse("Something went wrong"));
            }
        }
Beispiel #2
0
        public HttpResponseMessage GetByUsername([FromUri()] string username)
        {
            try
            {
                var crud = new AwsController();

                var results = crud.RetrieveChatByUsername(username);
                if (results.Count > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, results));
                }

                return(Request.CreateResponse("Chats not found."));
            }
            catch
            {
                return(Request.CreateResponse("Something went wrong"));
            }
        }
Beispiel #3
0
        public void Cleanup(int id)
        {
            var crud = new AwsController();

            crud.CleanupDbUnitTester(id);
        }