public async Task GetPersonAsync(Entities.PersonRequest request, OnGetPersonCompleted onGetPersonCompleted) { var graphClient = AuthenticationHelper.Instance.GetAuthenticatedClient(); if (AuthenticationHelper.Instance.ServiceException.Error == ServiceError.AuthenticationClientError) { request.expection = AuthenticationHelper.Instance.ServiceException; onGetPersonCompleted(request); return; } if (graphClient != null) { try { User user = request.id == "" ? await graphClient.Me.Request().GetAsync() : await graphClient.Users[request.id].Request().GetAsync(); if (request.id == "") { request.id = user.Id; } request.person = new PersonEntity() { FullName = user.DisplayName, Surname = user.Surname, GivenName = user.GivenName, JobTitle = user.JobTitle, Department = user.Department, OfficeLocation = user.OfficeLocation, PhoneNumber = user.MobilePhone, EmailAddress = user.Mail, Id = user.Id, PhotoDetail = await GetPhotoAsync(request.id) }; } catch (Exception ex) { request.expection.Error = ServiceError.UserError; request.expection.Exception = ex; } } onGetPersonCompleted(request); }
public void GetPerson(Entities.PersonRequest request, OnGetPersonCompleted onGetPersonCompleted) { System.Threading.Tasks.Task.Run( () => GetPersonAsync(request, onGetPersonCompleted)); }