Example #1
0
        // POST: api/Hook/value
        public async Task <dynamic> Post()
        {
            string result = await Request.Content.ReadAsStringAsync();

            //dynamic dynMessageString = JsonConvert.DeserializeObject(result);
            if (result != null)
            {
                try
                {
                    dynamic dynMessage = JsonConvert.DeserializeObject(result);
                    Message msg        = Messages.GetMessage(dynMessage.message_id.ToString());
                    Clients clients    = new Clients();
                    Client  client     = clients.GetClient(Int32.Parse(msg.clientID));

                    Msg message = new Msg
                    {
                        text          = msg.text,
                        ID            = msg.ID,
                        Transport     = msg.transport,
                        type          = msg.type,
                        Name          = client.name,
                        Phone         = client.phone,
                        dialog        = dynMessage.dialog_id,
                        Date          = msg.created,
                        external_id   = client.external_id,
                        assigned_name = client.assigned_name
                    };
                    MessagesList.Messages.Add(message);
                    Configer.WritePool(MessagesList.Messages);
                    Error = null;
                }
                catch (Exception ex)
                {
                    Error = ex.Message;
                }
            }
            HookCount++;
            value = result;
            return(Ok());
        }