Exemplo n.º 1
0
 /// <param name='operations'>
 /// Reference to the Api.Sdk.IBorrower.
 /// </param>
 /// <param name='borrower'>
 /// Required.
 /// </param>
 public static BorrowerDto PostByBorrower(this IBorrower operations, BorrowerDto borrower)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IBorrower)s).PostByBorrowerAsync(borrower);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 2
0
        public async Task <BorrowerDto> Update(BorrowerDto borrowerDto)
        {
            IBorrower borrower = await BorrowerFactory.FetchAsync(borrowerDto.Id);

            borrower.Position           = borrowerDto.Position;
            borrower.EDisclosureConsent = borrowerDto.EDisclosureConsent;
            borrower.EmailConsent       = borrowerDto.EmailConsent;
            borrower.EmailAddress       = borrowerDto.EmailAddress;

            borrower = await borrower.SaveAsync() as IBorrower;

            return(new BorrowerDto
            {
                PartnerId = borrower.PartnerId,
                CobranderId = borrower.CobranderId,
                SiteProfileId = borrower.SiteProfileId,
                AccountId = borrower.AccountId,
                Id = borrower.Id,
                Position = borrower.Position,
                EDisclosureConsent = borrower.EDisclosureConsent,
                EmailConsent = borrower.EmailConsent,
                EmailAddress = borrower.EmailAddress
            });
        }
Exemplo n.º 3
0
        public async Task <BorrowerDto> Insert(BorrowerDto borrowerDto)
        {
            IBorrower borrower = await BorrowerFactory.CreateAsync(new Tuple <Guid, Guid, Guid, Guid>(borrowerDto.PartnerId, borrowerDto.CobranderId, borrowerDto.SiteProfileId, borrowerDto.AccountId));

            borrower.Position           = borrowerDto.Position;
            borrower.EDisclosureConsent = borrowerDto.EDisclosureConsent;
            borrower.EmailConsent       = borrowerDto.EmailConsent;
            borrower.EmailAddress       = borrowerDto.EmailAddress;

            borrower = await borrower.SaveAsync() as IBorrower;

            return(new BorrowerDto
            {
                PartnerId = borrower.PartnerId,
                CobranderId = borrower.CobranderId,
                SiteProfileId = borrower.SiteProfileId,
                AccountId = borrower.AccountId,
                Id = borrower.Id,
                Position = borrower.Position,
                EDisclosureConsent = borrower.EDisclosureConsent,
                EmailConsent = borrower.EmailConsent,
                EmailAddress = borrower.EmailAddress
            });
        }
Exemplo n.º 4
0
 public async Task <BorrowerDto> Post(BorrowerDto borrower)
 {
     return(await BorrowerService.Insert(borrower));
 }
Exemplo n.º 5
0
 public async Task <BorrowerDto> Put(BorrowerDto borrower)
 {
     return(await BorrowerService.Update(borrower));
 }
Exemplo n.º 6
0
        /// <param name='operations'>
        /// Reference to the Api.Sdk.IBorrower.
        /// </param>
        /// <param name='borrower'>
        /// Required.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public static async Task <BorrowerDto> PutByBorrowerAsync(this IBorrower operations, BorrowerDto borrower, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Microsoft.Rest.HttpOperationResponse <Api.Sdk.Models.BorrowerDto> result = await operations.PutByBorrowerWithOperationResponseAsync(borrower, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
Exemplo n.º 7
0
        /// <param name='borrower'>
        /// Required.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public async Task <HttpOperationResponse <BorrowerDto> > PutByBorrowerWithOperationResponseAsync(BorrowerDto borrower, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // Validate
            if (borrower == null)
            {
                throw new ArgumentNullException("borrower");
            }

            // Tracing
            bool   shouldTrace  = ServiceClientTracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("borrower", borrower);
                ServiceClientTracing.Enter(invocationId, this, "PutByBorrowerAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/api/v1/Borrower";
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();

            httpRequest.Method     = HttpMethod.Put;
            httpRequest.RequestUri = new Uri(url);

            // Set Headers

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }

            // Serialize Request
            string requestContent = null;
            JToken requestDoc     = borrower.SerializeJson(null);

            requestContent      = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented);
            httpRequest.Content = new StringContent(requestContent, Encoding.UTF8);
            httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");

            // Send Request
            if (shouldTrace)
            {
                ServiceClientTracing.SendRequest(invocationId, httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            if (shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
            }
            HttpStatusCode statusCode = httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (statusCode != HttpStatusCode.OK)
            {
                HttpOperationException <object> ex = new HttpOperationException <object>();
                ex.Request  = httpRequest;
                ex.Response = httpResponse;
                ex.Body     = null;
                if (shouldTrace)
                {
                    ServiceClientTracing.Error(invocationId, ex);
                }
                throw ex;
            }

            // Create Result
            HttpOperationResponse <BorrowerDto> result = new HttpOperationResponse <BorrowerDto>();

            result.Request  = httpRequest;
            result.Response = httpResponse;

            // Deserialize Response
            if (statusCode == HttpStatusCode.OK)
            {
                BorrowerDto resultModel = new BorrowerDto();
                JToken      responseDoc = null;
                if (string.IsNullOrEmpty(responseContent) == false)
                {
                    responseDoc = JToken.Parse(responseContent);
                }
                if (responseDoc != null)
                {
                    resultModel.DeserializeJson(responseDoc);
                }
                result.Body = resultModel;
            }

            if (shouldTrace)
            {
                ServiceClientTracing.Exit(invocationId, result);
            }
            return(result);
        }
Exemplo n.º 8
0
        /// <param name='borrowerId'>
        /// Required.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public async Task <HttpOperationResponse <BorrowerDto> > GetByBorroweridWithOperationResponseAsync(string borrowerId, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // Validate
            if (borrowerId == null)
            {
                throw new ArgumentNullException("borrowerId");
            }

            // Tracing
            bool   shouldTrace  = ServiceClientTracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("borrowerId", borrowerId);
                ServiceClientTracing.Enter(invocationId, this, "GetByBorroweridAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/api/v1/Borrower";
            List <string> queryParameters = new List <string>();

            queryParameters.Add("borrowerId=" + Uri.EscapeDataString(borrowerId));
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();

            httpRequest.Method     = HttpMethod.Get;
            httpRequest.RequestUri = new Uri(url);

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }

            // Send Request
            if (shouldTrace)
            {
                ServiceClientTracing.SendRequest(invocationId, httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            if (shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
            }
            HttpStatusCode statusCode = httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NotFound)
            {
                HttpOperationException <object> ex = new HttpOperationException <object>();
                ex.Request  = httpRequest;
                ex.Response = httpResponse;
                ex.Body     = null;
                if (shouldTrace)
                {
                    ServiceClientTracing.Error(invocationId, ex);
                }
                throw ex;
            }

            // Create Result
            HttpOperationResponse <BorrowerDto> result = new HttpOperationResponse <BorrowerDto>();

            result.Request  = httpRequest;
            result.Response = httpResponse;

            // Deserialize Response
            if (statusCode == HttpStatusCode.OK)
            {
                BorrowerDto resultModel = new BorrowerDto();
                JToken      responseDoc = null;
                if (string.IsNullOrEmpty(responseContent) == false)
                {
                    responseDoc = JToken.Parse(responseContent);
                }
                if (responseDoc != null)
                {
                    resultModel.DeserializeJson(responseDoc);
                }
                result.Body = resultModel;
            }

            if (shouldTrace)
            {
                ServiceClientTracing.Exit(invocationId, result);
            }
            return(result);
        }