private async Task <RepairPeople> GetRepairPeopleByEmailAddress(string userPrincipalName) { AuthenticationHelper adHelp = new AuthenticationHelper(); Microsoft.Azure.ActiveDirectory.GraphClient.User repairPeople = await adHelp.GetADUserByPrincipalName(userPrincipalName); RepairPeople retRepairPeople = null; if (repairPeople != null) { retRepairPeople = new RepairPeople() { Title = repairPeople.DisplayName, sl_emailaddress = repairPeople.UserPrincipalName }; } return(retRepairPeople); /*string resturl = "/_api/lists/GetByTitle('Repair People')/Items?" + "$select=Id,Title,sl_accountname,sl_emailaddress" + string.Format("&$Filter=(Id eq {0})", id); + + string responseString = await RestHelper.GetRestData(resturl, _token); + + return JObject.Parse(responseString)["d"]["results"].ToObject<RepairPeople[]>().FirstOrDefault();*/ }
private async Task <List <RepairPeople> > GetRepairPeople() { /* string resturl = "/_api/lists/GetByTitle('Repair People')/Items?" + "$select=Id,Title,sl_accountname,sl_emailaddress"; + + string responseString = await RestHelper.GetRestData(resturl, _token); + + return JObject.Parse(responseString)["d"]["results"].ToObject<RepairPeople[]>();*/ List <RepairPeople> repairlist = new List <RepairPeople>(); AuthenticationHelper adHelp = new AuthenticationHelper(); List <Microsoft.Azure.ActiveDirectory.GraphClient.User> allUsers = await adHelp.GetADUsersByGroupName("Repair People"); foreach (Microsoft.Azure.ActiveDirectory.GraphClient.User user in allUsers) { RepairPeople repairPeople = new RepairPeople() { Title = user.DisplayName, sl_emailaddress = user.UserPrincipalName }; repairlist.Add(repairPeople); } return(repairlist); }
private async Task<RepairPeople> GetRepairPeopleByEmailAddress(string userPrincipalName) { AuthenticationHelper adHelp = new AuthenticationHelper(); Microsoft.Azure.ActiveDirectory.GraphClient.User repairPeople = await adHelp.GetADUserByPrincipalName(userPrincipalName); RepairPeople retRepairPeople = null; if(repairPeople!=null) { retRepairPeople= new RepairPeople() { Title = repairPeople.DisplayName, sl_emailaddress = repairPeople.UserPrincipalName }; } return retRepairPeople; /*string resturl = "/_api/lists/GetByTitle('Repair People')/Items?" + "$select=Id,Title,sl_accountname,sl_emailaddress" + string.Format("&$Filter=(Id eq {0})", id); string responseString = await RestHelper.GetRestData(resturl, _token); return JObject.Parse(responseString)["d"]["results"].ToObject<RepairPeople[]>().FirstOrDefault();*/ }
private async Task<List<RepairPeople>> GetRepairPeople() { /* string resturl = "/_api/lists/GetByTitle('Repair People')/Items?" + "$select=Id,Title,sl_accountname,sl_emailaddress"; string responseString = await RestHelper.GetRestData(resturl, _token); return JObject.Parse(responseString)["d"]["results"].ToObject<RepairPeople[]>();*/ List<RepairPeople> repairlist = new List<RepairPeople>(); AuthenticationHelper adHelp = new AuthenticationHelper(); List<Microsoft.Azure.ActiveDirectory.GraphClient.User> allUsers = await adHelp.GetADUsersByGroupName("Repair People"); foreach(Microsoft.Azure.ActiveDirectory.GraphClient.User user in allUsers) { RepairPeople repairPeople = new RepairPeople() { Title = user.DisplayName, sl_emailaddress = user.UserPrincipalName }; repairlist.Add(repairPeople); } return repairlist; }