예제 #1
0
        public async Task<ServiceReturn<bool>> UploadProfilePhotoAsync(AuthenticationType tipoAuth, byte[] photo, string extension, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(errorMessage))
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            else
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.Error);
            if (!string.IsNullOrEmpty(successMessage))
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);

            bool uploadSuccess = false;
            try
            {
                string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL");
                Generated.PatientDataClient sc = new Generated.PatientDataClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                await sc.PostUploadProfilePhotoAsync(photo, extension, GetGPAppVersion());

                uploadSuccess = true;

                return ServiceReturnHandling.BuildSuccessCallReturn<bool>(uploadSuccess, uiMessages);
            }
            catch (Exception ex)
            {
                return ServiceReturnHandling.HandleException<bool>(ex, uiMessages);
            }
        }
예제 #2
0
        public async Task<ServiceReturn<byte[]>> DownloadProfilePhotoAsync(AuthenticationType tipoAuth, string successMessage = "", string errorMessage = "")
        {
            var uiMessages = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(errorMessage))
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, errorMessage);
            else
                uiMessages.Add(ServiceReturnHandling.GenericMessageKey, AppResources.Error);
            if (!string.IsNullOrEmpty(successMessage))
                uiMessages.Add(ServiceReturnHandling.SuccessMessageKey, successMessage);

            try
            {
                string baseUrl = await CommunicationManager.ServiceManager.GetServiceEndpoint("GP_BASE_URL");
                Generated.PatientDataClient sc = new Generated.PatientDataClient(baseUrl, await CommunicationManager.Instance.GetHttpClientWithToken(tipoAuth, new HttpClient()));
                var result = await sc.GetDownloadPatientPhotoAsync(string.Empty, "300", "300", GetGPAppVersion());

                return ServiceReturnHandling.BuildSuccessCallReturn<byte[]>(result, uiMessages);
            }
            catch (Exception ex)
            {
                return ServiceReturnHandling.HandleException<byte[]>(ex, uiMessages);
            }
        }