public static MessageModel ParseMessage(Message message)
 {
     return new MessageModel(
         message.Id,
         UserModel.ParseUser(message.Sender),
         message.Content,
         message.Time);
 }
        // POST api/chats/id
        public MessageModel Post(int id, [FromBody]MessageModel message)
        {
            var chat = this.chatsRepository.Get(id);
            Message currentMessage = new Message();

            currentMessage.Sender = this.usersRepository.Get(message.Sender.Id);
            if (currentMessage.Sender == null)
            {
                throw new Exception(string.Format("User with ID's = {0} not found", message.Sender.Id));
            }

            currentMessage.Content = message.Content;
            currentMessage.Time = message.Time;

            chat.Messages.Add(currentMessage);
            this.chatsRepository.Update(id, chat);

            foreach (var user in chat.Participants)
            {
                if (user.Username != currentMessage.Sender.Username)
                {
                    string jsonObject = "{ \"ChatId\":\"" + id + "\", \"MessageId\":\"" + currentMessage.Id + "\",\"UserId\":\"" + currentMessage.Sender.Id + "\" }";
                    PubnubController.Push(user.Username, jsonObject);
                }
            }

            return MessageModel.ParseMessage(currentMessage);
        }