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);
        }
Example #2
0
 public void GetPerson(PersonRequest request, OnGetPersonCompleted onGetPersonCompleted)
 {
 }
Example #3
0
 public void GetCurrentUser(OnGetPersonCompleted onGetPersonCompleted)
 {
 }
 public void GetPerson(Entities.PersonRequest request, OnGetPersonCompleted onGetPersonCompleted)
 {
     System.Threading.Tasks.Task.Run(
         () => GetPersonAsync(request, onGetPersonCompleted));
 }
 public void GetCurrentUser(OnGetPersonCompleted onGetPersonCompleted)
 {
     System.Threading.Tasks.Task.Run(
         () => GetPersonAsync(new Entities.PersonRequest(), onGetPersonCompleted));
 }