public async Task Audit() { var queuePublishService = new Mock <IQueuePublishService <AuditingDto> >(); queuePublishService.Setup(x => x.PublishAsync(It.IsAny <AuditingDto>())).Returns(Task.FromResult(1)); IAuditor auditor = new Auditor(queuePublishService.Object); await auditor.AuditAsync( "Source", AuditEventType.JobStarted, "UserId", 99999, "Filename", "UkPrn", "ExtraInfo"); queuePublishService.Verify(); }
public async Task <MultiTraderCreditProviderBeginTransferResponse> BeginTransferAsync(MultiTraderCreditProviderBeginTransferRequest request, CancellationToken cancellation) { var response = new MultiTraderCreditProviderBeginTransferResponse(); var args = new { Result = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), Key = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), TraderKey = request.TraderKey, request.FromUserName, request.ToUserName, request.Amount, request.FromInfo, request.ToInfo }; var dbr = await Db.ExecuteNonQueryAsync("usp1_CreditTransaction_begin_transfer", args, cancellation); if (dbr.Success) { response.Status = args.Result.Value?.ToString(); var ar = await Auditor.AuditAsync("CRD_BGNTRNSFR", $"{{tk:{request.TraderKey},fu:{request.FromUserName},tu:{request.ToUserName},m:{request.Amount}}}"); if (ar.IsSucceeded()) { if (response.Status == "Success") { response.Succeeded(args.Key.Value); } } else { response.Exception = ar.Exception; response.Status = "AuditError"; } } else { response.Failed(dbr.Exception); } return(response); }
private async Task <MultiTraderCreditProviderBeginApplyResponse> BeginApplyAsync(MultiTraderCreditProviderBeginApplyRequest request, CancellationToken cancellation) { var response = new MultiTraderCreditProviderBeginApplyResponse(); var args = new { Result = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), Key = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), TraderKey = request.TraderKey, UserName = request.UserName, Amount = request.Amount, Info = request.Info }; var dbr = await Db.ExecuteNonQueryAsync("usp1_CreditTransaction_begin_apply", args, cancellation); if (dbr.Success) { response.Status = args.Result.Value?.ToString(); var ar = await Auditor.AuditAsync(request.AuditCode, $"{{tk:{request.TraderKey},u:{request.UserName},m:{request.Amount}}}"); if (ar.IsSucceeded()) { if (response.Status == "Success") { response.Succeeded(args.Key.Value); } } else { response.Exception = ar.Exception; response.Status = "AuditError"; } } else { response.Failed(dbr.Exception); } return(response); }
public async Task <SingleTraderCreditProviderEndTransferResponse> EndTransferAsync(SingleTraderCreditProviderEndTransferRequest request, CancellationToken cancellation) { var response = new SingleTraderCreditProviderEndTransferResponse(); var args = new { Result = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), Key = CommandParameter.Output(System.Data.SqlDbType.VarChar, 50), TransactionKey = request.TransactionKey }; var dbr = await Db.ExecuteNonQueryAsync("usp1_Credit_singletrader_end_transfer", args, cancellation); if (dbr.Success) { response.Status = args.Result.Value?.ToString(); var ar = await Auditor.AuditAsync("CRD_ENDTRNSFR", $"{{trnk:{request.TransactionKey}}}"); if (ar.IsSucceeded()) { if (response.Status == "Success") { response.Succeeded(); } } else { response.Exception = ar.Exception; response.Status = "AuditError"; } } else { response.Failed(dbr.Exception); } return(response); }