public async void getAllUsers()
        {
            var userUrl = "/api/messages/showall?username=" + scherm.GetUser().username;
            HttpResponseMessage response = await client.GetAsync(userUrl);

            IEnumerable <Message> t = null;

            if (response.IsSuccessStatusCode)
            {
                t = await response.Content.ReadAsAsync <List <Message> >();

                articlesDataGrid.ItemsSource = t;
                messages = t;
            }
        }
        public async void GetAllNames()
        {
            var userUrl = "/api/users/names";
            HttpResponseMessage response = await client.GetAsync(userUrl);

            List <String> t = null;

            if (response.IsSuccessStatusCode)
            {
                t = await response.Content.ReadAsAsync <List <String> >();

                t.Remove(scherm.GetUser().username);
                if (t.Count != 0)
                {
                    chatterList.ItemsSource = t;
                }
                else
                {
                    chatterList.Visibility = Visibility.Collapsed;
                }
            }
        }
Esempio n. 3
0
        public async void loadData()
        {
            var userUrl = "/api/messages/countAll";
            HttpResponseMessage response = await client.GetAsync(userUrl);

            if (response.IsSuccessStatusCode)
            {
                StatsSource s = await response.Content.ReadAsAsync <StatsSource>();

                welcomeBlock.Text  = "Welcome, " + scherm.GetUser().username + "!";
                messagesBlock.Text = s.totalMessages;
                usersBlock.Text    = s.totalUsers;
            }
        }
Esempio n. 4
0
        public MessagePage()
        {
            InitializeComponent();

            menuBox.SelectionChanged += MenuBox_SelectionChanged;
            ServicePointManager.ServerCertificateValidationCallback += (send, certificate, chain, sslPolicyErrors) => { return(true); };
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
            scherm             = (HomeWindow)Application.Current.MainWindow;
            client.BaseAddress = new Uri(Adress.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
                "Basic",
                Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "basic_security", "2018"))));

            Sender = scherm.GetUser();
            GetAllNames();
        }
 private async void Logout()
 {
     var userUrl = "/api/users/logout?username=" + scherm.GetUser().username;
     HttpResponseMessage response = await client.GetAsync(userUrl);
 }