Beispiel #1
0
        public async static Task <EmployeeOrgModel> GetEmployeeModel(string path)
        {
            EmployeeOrgModel data = new EmployeeOrgModel();

            //get the access token for calling into the graph
            var token = await GetAccessTokenForResource("https://graph.microsoft.com/");

            //get the user
            var json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}", path), token);

            data.Employee = JsonConvert.DeserializeObject <EmployeeModel>(json);

            //get the manager...might not exist
            json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}/manager", path), token);

            if (json == null)
            {
                data.Manager = new EmployeeModel();
            }
            else
            {
                data.Manager = JsonConvert.DeserializeObject <EmployeeModel>(json);
            }

            //get the direct reports
            json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}/directReports", path), token);

            data.DirectReports = JObject.Parse(json).SelectToken("value").ToObject <List <EmployeeModel> >();

            return(data);
        }
Beispiel #2
0
        private async void refreshView(string path)
        {
            wait.Visibility = Visibility.Visible;
            var data = await EmployeeOrgModel.GetEmployeeModel(path);

            this.DataContext = data;
            wait.Visibility  = Visibility.Collapsed;
        }
        public async static Task<EmployeeOrgModel> GetEmployeeModel(string path)
        {
            EmployeeOrgModel data = new EmployeeOrgModel();

            //get the access token for calling into the graph
            var token = await GetAccessTokenForResource("https://graph.microsoft.com/");

            //get the user
            var json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}", path), token);
            data.Employee = JsonConvert.DeserializeObject<EmployeeModel>(json);

            //get the manager...might not exist
            json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}/manager", path), token);
            if (json == null)
                data.Manager = new EmployeeModel();
            else
                data.Manager = JsonConvert.DeserializeObject<EmployeeModel>(json);

            //get the direct reports
            json = await GetJson(String.Format("https://graph.microsoft.com/beta/{0}/directReports", path), token);
            data.DirectReports = JObject.Parse(json).SelectToken("value").ToObject<List<EmployeeModel>>();

            return data;
        }
Beispiel #4
0
        private async void Manager_Tapped(object sender, TappedRoutedEventArgs e)
        {
            EmployeeOrgModel model = (EmployeeOrgModel)((TextBlock)sender).DataContext;

            refreshView("myorganization/users/" + model.Manager.objectId);
        }