public ActionResult GetAccountTransactionHistory(string accountId)
        {
            var response = new GenericResponse <string>();

            try
            {
                var result = _transactionService.GetAccountTransactionHistory(accountId);

                if (result.IsSuccess)
                {
                    var stream = result.Data.ToCSV(new List <string>()
                    {
                        "Wallet", "Amount"
                    }).ToStream();
                    return(File(stream, "application/octet-stream", $"{accountId }- History.csv"));
                }
                else
                {
                    response.Failed("Failed To get History");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                response.Failed("Something went wrong");
            }

            return(Ok(response));
        }
Exemple #2
0
        private async Task <IActionResult> AuthTest(string projectId, string resultOutcome)
        {
            try
            {
                using var session = _documentStore.OpenAsyncSession();
                var user = await _platformAdminUserManager.GetByUniqueIdentifierAsync(User.Identity.Name, session);

                var testMode = TestProjectId.IsValidIdentity(projectId) && !ProjectId.IsValidIdentity(projectId);
                var project  = testMode ? await _projectManager.GetTest((TestProjectId)projectId, session) : await _projectManager.Get((ProjectId)projectId, session);

                var result = await _applicationTestHttpClient.SendAuthCallback(project.Applications.First(), Guid.NewGuid().ToString(), resultOutcome, Guid.NewGuid().ToString());

                return(Ok(result));
            }
            catch (ApiException ex)
            {
                _logger.LogError(ex, "Unable to test application. {@request}", projectId);
                // return error message if there was an exception

                return(Ok(GenericResponse.Failed(ex.Message, (System.Net.HttpStatusCode)ex.StatusCode)));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Unable to test application. {@request}", projectId);
                // return error message if there was an exception

                return(Ok(GenericResponse.Failed(ex.Message, System.Net.HttpStatusCode.BadRequest)));
            }
        }
        public async Task <ActionResult> AddAccounts(AddAccounts accounts)
        {
            var response = new GenericResponse <List <DiscoveryPatchResponse> >();

            try
            {
                var addedAccounts = _transactionService.AddAccounts(accounts.AccountsIds);
                if (addedAccounts.IsSuccess)
                {
                    var discoveryResult = await _transactionService.DiscoverPayments(addedAccounts.Data);

                    if (discoveryResult.IsSuccess)
                    {
                        var responseData = new List <DiscoveryPatchResponse>();
                        discoveryResult.Data.ForEach(d =>
                        {
                            responseData.Add(new DiscoveryPatchResponse()
                            {
                                AccountId          = d.Account.PublicKey,
                                IsSuccess          = d.Status == PatchStatus.Success,
                                PulledRecordsCount = d.PulledRecordsCount
                            });
                        });
                        response.Success(responseData);
                    }
                    else
                    {
                        response.Failed("Failed to discover payments");
                    }
                }
                else
                {
                    response.Failed("Failed to Add Account to Database Please check Logs");
                }
            }
            catch (Exception ex)
            {
                response.Failed("Failed to Add Account to Database or discover paymets  Please check Logs");
            }
            return(Ok(response));
        }
Exemple #4
0
        public async Task <IActionResult> Data([FromRoute] string projectType, [FromRoute] string id)
        {
            var projectId = $"{projectType}/{id}";

            _logger.LogInformation("Dummy data url test for {projectId}", projectId);
            using var session = _documentStore.OpenAsyncSession();
            //var user = await _platformAdminUserManager.GetByUniqueIdentifierAsync(User.Identity.Name, session);
            var testMode = TestProjectId.IsValidIdentity(projectId) && !ProjectId.IsValidIdentity(projectId);
            var project  = testMode ? await _projectManager.GetTest((TestProjectId)projectId, session) : await _projectManager.Get((ProjectId)projectId, session);

            var payload = DummyPayload(project.Name, project.Applications.FirstOrDefault()?.SecretKey);

            try
            {
                var result = await _applicationTestHttpClient.SendDataTest(project.Applications.First(), payload);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Unable to test application. {@request}", projectId);
                return(Ok(GenericResponse.Failed(ex.Message, System.Net.HttpStatusCode.BadRequest)));
            }
        }