Esempio n. 1
0
        //Handle send message event from Staff side
        public void StaffSend(string namesend, string message, string connectionID, string idconversation)
        {
            var idconn = Convert.ToInt32(idconversation);
            var status = db.Conversations.Where(x => x.IdConversation == idconn).FirstOrDefault().Status;

            if (status == true)
            {
                db.NewMessage(idconn, Convert.ToInt32(connectionID), 1);
                db.SaveMessage(idconn, false, message);
                var allconn = db.getAllConn(Convert.ToInt32(connectionID)).ToList();
                foreach (var item in allconn)
                {
                    //JS from Satff side is different from User side / update code later
                    Clients.Client(item.Conn).addNewMessageToPage(namesend, message);
                }
                Clients.Client(Context.ConnectionId).addNotificationToPage("Đã gửi");
            }
            else
            {
                Clients.Client(Context.ConnectionId).addNotificationToPage("4");
            }
        }