Ejemplo n.º 1
0
        public IActionResult BarcodePart([FromQuery] GetPartRequest request)
        {
            var stream = new MemoryStream();
            var image  = _barcodeGenerator.GenerateBarcode(request.PartNumber, 300, 25);

            image.Save(stream, ImageFormat.Png);
            stream.Seek(0, SeekOrigin.Begin);
            return(new FileStreamResult(stream, "image/png"));
        }
        public override Task <GetPaymentsResult> GetPart(GetPartRequest request, ServerCallContext context)
        {
            var payments = paymentsRepository.Get(request.Part, request.TotalParts, request.Timestamp.ToDateTime());
            var mapped   = payments.Where(payment => payment != null)
                           .Select(p => mapper.Map <Payment>(p))
                           .ToArray();

            return(Task.FromResult(new GetPaymentsResult {
                Payments = { mapped }
            }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetAsync(GetPartRequest request)
        {
            var part = await _partService.GetPartAsync(request.PartNumber);

            if (part == null)
            {
                return(NotFound());
            }
            var partResponse = Mapper.Map <Part, PartResponse>(part);
            var partTypes    = await _partService.GetPartTypesAsync();

            partResponse.PartType = partTypes.Where(x => x.PartTypeId == part.PartTypeId).Select(x => x.Name).FirstOrDefault();
            return(Ok(partResponse));
        }
        public override async Task <GetDataToProcessResponse> Get(GetDataToProcessRequest request, ServerCallContext context)
        {
            var paymentsAndLoansRequest = new GetPartRequest {
                Part = request.Part, TotalParts = request.TotalParts, Timestamp = request.Timestamp
            };
            var paymentsAndLoans = await paymentsClient.GetPartAsync(paymentsAndLoansRequest, context.RequestHeaders.SelectCustom());

            var paymentAccounts = paymentsAndLoans.Payments.Select(p => p.AccountId).Distinct();
            var accountsRequest = new GetBalancesRequest {
                Ids = { paymentAccounts }
            };
            var balances = await accountsClient.GetBalancesAsync(accountsRequest, context.RequestHeaders.SelectCustom());

            return(new GetDataToProcessResponse
            {
                Payments = { paymentsAndLoans.Payments },
                Loans = { paymentsAndLoans.Loans },
                Balances = { balances.Balances }
            });
        }
Ejemplo n.º 5
0
        public override Task <GetPaymentsWithLoansResult> GetPart(GetPartRequest request, ServerCallContext context)
        {
            var payments = paymentsRepository.Get(request.Part, request.TotalParts, request.Timestamp.ToDateTime());

            return(WithLoans(payments, context.RequestHeaders.SelectCustom()));
        }