public async Task <ActionResult <users> > GetUsers() { users users = new users(); users.Totalusers = new List <UserModel>(); GraphServiceClient client = await _graphClient.GetServiceClient(); var userList = await client.Users.Request().GetAsync(); foreach (var user in userList) { var objUser = _dataHandler.UserProperty(user); users.Totalusers.Add(objUser); } users.totalResults = users.Totalusers.Count; return(users); }
public async Task <GroupList> GetAllGroups() { try { GroupList ListGroup = new GroupList(); ListGroup.Groups = new List <GetGroupModel>(); GraphServiceClient graphClient = await _graphClient.GetServiceClient(); var groups = await graphClient.Groups .Request() .GetAsync(); foreach (var eachGroup in groups) { var objGroup = _dataHandler.GroupBind(eachGroup); ListGroup.Groups.Add(objGroup); } ListGroup.totalCount = groups.Count; return(ListGroup); } catch (ServiceException) { return(null); } }