public List <Message> GetAllNotifications()
        {
            notifications = new List <Message>();
            SingletonDbConnect conn = SingletonDbConnect.getDbInstance();

            using (HomeController.command = new SqlCommand("select Id, Name, ChatId from dbo.Messages where ChatId = 28", conn.getDbConnection()))
            {
                HomeController.command.Notification = null;

                if (HomeController.dependency == null)
                {
                    SqlDependency dependency = new SqlDependency(HomeController.command);

                    dependency.OnChange += new OnChangeEventHandler(GetAllNotificationsDep_OnChange);
                    // HomeController.dependency = new SqlDependency(HomeController.command);
                    //    HomeController.dependency.OnChange += new OnChangeEventHandler(GetAllNotificationsDep_OnChange);
                }
                var reader = HomeController.command.ExecuteReader();


                while (reader.Read())
                {
                    var Message = new Message
                    {
                        Id     = Convert.ToInt32(reader["Id"]),
                        Name   = reader["Name"].ToString(),
                        ChatId = Convert.ToInt32(reader["ChatId"])
                    };

                    notifications.Add(Message);
                }
            }

            return(notifications);
        }
 public static SingletonDbConnect getDbInstance()
 {
     if (dbInstance == null)
     {
         dbInstance = new SingletonDbConnect();
     }
     return(dbInstance);
 }