// POST: api/Chats
        public IHttpActionResult PostChat(string username, string clienUsername, string message)
        {
            ChatModels chatModels = new ChatModels(db);
            DateTime   dateTime   = DateTime.Now;
            int        chatId     = chatModels.AddChat(username, clienUsername, dateTime, message);

            SendNotificationWithFirebaseProvider provider = new SendNotificationWithFirebaseProvider();
            string deviceId = db.Users.Where(u => u.UserName == clienUsername).FirstOrDefault().FirebaseDeviceToken;

            if (deviceId != null && deviceId.Length > 0)
            {
                provider.SendPush(new PushMessage
                {
                    to           = deviceId,
                    notification = new PushMessageData
                    {
                        title = "Hadis diplome project",
                        text  = "Новое сообщение"
                    },
                    data = new
                    {
                        chatId = chatId + ""
                    }
                });
            }

            return(Ok());
        }
        // POST: api/ChatMessages
        public async Task <IHttpActionResult> PostChatMessage(int chatId, string username, string message)
        {
            ChatModels chatModels = new ChatModels(db);
            DateTime   dateTime   = DateTime.Now;

            chatModels.AddMessage(chatId, username, message, dateTime);

            await db.SaveChangesAsync();

            SendNotificationWithFirebaseProvider provider = new SendNotificationWithFirebaseProvider();
            string opponentUsername = chatModels.GetOpponentUsername(chatId, username);
            string deviceId         = db.Users.Where(u => u.UserName == opponentUsername).FirstOrDefault().FirebaseDeviceToken;

            if (deviceId != null && deviceId.Length > 0)
            {
                provider.SendPush(new PushMessage
                {
                    to           = deviceId,
                    notification = new PushMessageData
                    {
                        title = "Hadis diplome project",
                        text  = "Новое сообщение"
                    },
                    data = new
                    {
                        chatId = chatId + ""
                    }
                });
            }

            return(Ok());
        }