Пример #1
0
        public async Task <TransactionResponseViewModel> GetTransactionById(string id)
        {
            var url = $"{_configuration["TransactionAPIUrl"]}/api/Transaction/{id}";

            try
            {
                var responseString = await HTTPRequestSender.GetAsync(url);

                return(JsonConvert.DeserializeObject <TransactionResponseViewModel>(responseString));
            }
            catch (Exception e)
            {
                var errorResponse = JsonConvert.DeserializeObject <ErrorResponseViewModel>(e.Message);

                if (errorResponse.Id == (int)ErrorResponseIds.InvalidTransaction)
                {
                    throw new InvalidTransactionException();
                }
                throw new Exception("Unknown Exception");
            }
        }
Пример #2
0
        public async Task <UserResponseViewModel> GetUserByCNP(string CNP)
        {
            var url = $"{_configuration["UserServiceAPIUrl"]}/api/User/GetUserByCNP/{CNP}";

            try
            {
                var responseString = await HTTPRequestSender.GetAsync(url);

                return(JsonConvert.DeserializeObject <UserResponseViewModel>(responseString));
            }
            catch (Exception e)
            {
                var errorResponse = JsonConvert.DeserializeObject <ErrorResponseViewModel>(e.Message);

                if (errorResponse.Id == (int)ErrorResponseIds.UserInvalid)
                {
                    throw new UserNotFoundException();
                }
                throw new Exception("Unknown Exception");
            }
        }
Пример #3
0
        public async Task <List <InvoiceResponseViewModel> > GetAllEONInvoice(string CNP)
        {
            var url = $"{_configuration["EONGazAPIUrl"]}/api/invoice/UserInvoices/{CNP}";

            try
            {
                var responseString = await HTTPRequestSender.GetAsync(url);

                return(JsonConvert.DeserializeObject <List <InvoiceResponseViewModel> >(responseString));
            }
            catch (Exception e)
            {
                var errorResponse = JsonConvert.DeserializeObject <ErrorResponseViewModel>(e.Message);

                if (errorResponse.Id == (int)ErrorResponseIds.InvoiceNotExist)
                {
                    throw new InvoiceNotExistException();
                }
                throw new Exception("Unknown Exception");
            }
        }