Beispiel #1
0
        /*
         *  Other Functions
         */

        public static DataToSendNotification[] GetNotificationData(int user_id)
        {
            var numRows = GetNumNotifications(user_id);
            var data    = new DataToSendNotification[numRows];

            var command = new SqliteCommand("SELECT * FROM Notifications WHERE USER_ID=@user_id AND SEEN=0", conn);

            command.Parameters.Add(new SqliteParameter("@user_id", user_id));
            var reader = command.ExecuteReader();

            var i = 0;

            while (reader.Read())
            {
                //Console.WriteLine(reader["MESSAGE"]);
                data[i]                = new DataToSendNotification();
                data[i].type           = "notification";
                data[i].senderName     = GetUsername(reader["SENDER_ID"].ToString());
                data[i].roomName       = GetRoomName(reader["ROOM_ID"].ToString());
                data[i].timestamp      = reader["TIMESTAMP"].ToString();
                data[i].notificationId = Convert.ToInt32(reader["ID"].ToString());
                i++;
            }
            return(data);
        }
Beispiel #2
0
    async Task SendNotification(int notifiedUser_id, string senderName, int room_id, string timestamp, int notification_id)
    {
        var dataToSend = new DataToSendNotification();

        dataToSend.type           = "notification";
        dataToSend.senderName     = senderName;
        dataToSend.roomName       = DBHandler.GetRoomName(room_id);
        dataToSend.timestamp      = timestamp;
        dataToSend.notificationId = notification_id;

        await SendDataToUser(dataToSend, notifiedUser_id);
    }