Advertisement
Guest User

Untitled

a guest
May 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.10 KB | None | 0 0
  1. using System.Threading.Tasks;
  2. using CollectorAPI.Business.Logging;
  3. using CollectorAPI.Business.Models;
  4. using CollectorAPI.Business.Models.Response;
  5. using CollectorAPI.DataAccess.TestWorkSpace;
  6.  
  7. namespace CollectorAPI.DataAccess
  8. {
  9.     public class StatisticaDataAccess : DataAccessBase, IDataAccess
  10.     {
  11.         private readonly LiveScoreClient _client;
  12.  
  13.         public StatisticaDataAccess(ILogger logger) : base(logger)
  14.         {
  15.             // Instantiate LiveScoreSoap client and add requestInspectorBehavior to be able to log SOAP request and response
  16.             _client = new LiveScoreClient();
  17.             // Add base endpointbehaviour to client
  18.             _client.Endpoint.Behaviors.Add(EndpointBehavior);
  19.         }
  20.  
  21.         public async Task<CreditEvaluationResponse> GetCreditEvaluationAsync(string countryCode, string civicRegNo, string currencySymbol, decimal requestedAmount, decimal productNumber, string channel, decimal repaymentTimeInMonths, decimal currentDebtBalance, decimal applicationsLast24Hours, decimal applicationsLast7Days, decimal applicationsLast30Days, decimal activeApplications, string applicationInformation)
  22.         {
  23.             var workSpace = new LiveTestWorkSpace()
  24.             {
  25.                 CountryCode = countryCode,
  26.                 CivicRegNo = civicRegNo,
  27.                 CurrencySymbol = currencySymbol,
  28.                 RequestedAmount = requestedAmount,
  29.                 ProductNumber = productNumber,
  30.                 Channel = channel,
  31.                 RepaymentTimeInMonths = repaymentTimeInMonths,
  32.                 CurrentDebtBalance = currentDebtBalance,
  33.                 ApplicationsLast24Hours = applicationsLast24Hours,
  34.                 ApplicationsLast7Days = applicationsLast7Days,
  35.                 ApplicationsLast30Days = applicationsLast30Days,
  36.                 ActiveApplications = activeApplications,
  37.                 ApplicationInformation = applicationInformation,
  38.             };
  39.  
  40.             var authentication = GetAuthentication();
  41.             var response = await CreateRequestAsync(_client, async client => await client.LiveTestWorkSpaceAsync(workSpace, authentication));
  42.  
  43.             return new CreditEvaluationResponse
  44.             {
  45.                 ApprovedAmount = response.LiveTestWorkSpaceResponse.ApprovedAmount,
  46.                 Decision = CreditEvaluationDecision.Accepted,
  47.                 DecisionReason = response.LiveTestWorkSpaceResponse.DecisionReason,
  48.                 InterestRate = response.LiveTestWorkSpaceResponse.InterestRate,
  49.                 Score = response.LiveTestWorkSpaceResponse.Score,
  50.                 ScoreWeightedTotalScore = response.LiveTestWorkSpaceResponse.WeightedTotalScore,
  51.                 CreditProvider = response.LiveTestWorkSpaceResponse.CreditProvider,
  52.                 CreditReportId = response.LiveTestWorkSpaceResponse.CreditReportId,
  53.                
  54.                
  55.             };
  56.         }
  57.  
  58.         private Authentication GetAuthentication()
  59.         {
  60.             //TODO: move to configuration
  61.             return new Authentication() { Username = "test_user", Password = "Smartboard1234" };
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement