public async Task <string> GetProfileImageAsync()
        {
            var uri     = $"learning/UserData/user/image";
            var message = $"There was error while attempting to get profile image";

            return(await _apiContext.GetResourceAsync(uri, message));
        }
        public async Task <byte[]> GetDocToPdfFileAsync(Uri fileUrl, string ProjectId, string contentId, string fileExtension)
        {
            var uri       = $"learning/ProjectData/content/aspdf?document={fileUrl}&ProjectId={ProjectId}&contentId={contentId}&fileType={fileExtension}";
            var message   = $"There was error while attempting to retrieve converted PDF for document at {fileUrl}.";
            var pdfAsText = string.Empty;

            try
            {
                pdfAsText = await _apiContext.GetResourceAsync(uri, message);
            }

            catch (System.Net.Http.HttpRequestException ex)
            {
                //if (ex.Message == "404 (Not Found)")
                //	throw new Exceptions.FileNotFoundException($"The file at {fileUrl} cannot be found.", ex);
                //else
                //	throw new FileErrorException($"There was an error while attemping to get the bytes for the file at {fileUrl}", ex);
            }
            catch (Exception ex)
            {
                //throw new DataRepositoryException($"There was an error while attempting to get the file at {fileUrl}", ex);
            }

            return(Convert.FromBase64String(pdfAsText));
        }
Ejemplo n.º 3
0
        public async Task <byte[]> GetDocToPdfFileAsync(Uri fileUrl, string courseId, string contentId, string fileExtension)
        {
            try
            {
                var uri     = $"learning/CourseData/content/aspdf?document={fileUrl}&courseId={courseId}&contentId={contentId}&fileType={fileExtension}&lms={Preferences.LMS}";
                var message = $"There was error while attempting to retrieve converted PDF for document at {fileUrl}.";

                var pdfAsText = await _apiContext.GetResourceAsync(uri, message);

                return(Convert.FromBase64String(pdfAsText));
            }
            catch (InternetConnectionException)
            {
                throw;
            }
            catch (System.Net.Http.HttpRequestException ex)
            {
                if (ex.Message == "404 (Not Found)")
                {
                    throw new FileNotFoundException($"The file at {fileUrl} cannot be found.", ex);
                }
                else
                {
                    throw new FileErrorException($"There was an error while attemping to get the bytes for the file at {fileUrl}", ex);
                }
            }
            catch (Exception ex)
            {
                throw new DataRepositoryException($"There was an error while attempting to get the file at {fileUrl}", ex);
            }
        }
        public async Task <decimal> GetAccountBalanceAsync()
        {
            var uri     = $"learning/AccountData/user/accountsummary";
            var message = $"There was an error while attempting to get the account summary";

            var accountBalance = await _apiContext.GetResourceAsync <string, AccountSummaryDto>(uri, message);

            return(Convert.ToDecimal(accountBalance));
        }