예제 #1
0
        public Task Get(MessageContext context, GetLoansEvent inputEvent)
        {
            var loans = inputEvent.Ids.Select(id => loansRepository.Get(id))
                        .Where(loan => loan != null).ToArray();

            publishingRouter.Publish(context.ReplyTo, new SelectedLoansEvent {
                Loans = loans
            }, context.FlowId);
            return(Task.CompletedTask);
        }
예제 #2
0
        public override Task <GetLoansResponse> Get(GetLoansRequest request, ServerCallContext context)
        {
            var loans = request.Ids.Select(id => loansRepository.Get(id))
                        .Where(loan => loan != null)
                        .Select(loan => mapper.Map <Loan>(loan));

            return(Task.FromResult(new GetLoansResponse {
                Loans = { loans }
            }));
        }
예제 #3
0
        public override async Task <Empty> BatchRepayInstalments(BatchRepayInstalmentsRequest request, ServerCallContext context)
        {
            var paymentsToFinish = RepayInstalments(request);

            if (paymentsToFinish.Any())
            {
                var cancelPaymentsRequest = new CancelPaymentsRequest {
                    Ids = { paymentsToFinish }
                };
                await paymentsClient.CancelAsync(cancelPaymentsRequest, context.RequestHeaders.SelectCustom());
            }

            var repaidInstalments = request.Ids.Select(id => loansRepository.Get(id)).ToArray();

            if (repaidInstalments.Length > 0)
            {
                projectionChannel.Publish(context.RequestHeaders.GetFlowId(), new DataProjection <Models.Loan, string> {
                    Upsert = repaidInstalments
                });
            }
            return(new Empty());
        }
예제 #4
0
        public ActionResult Edit(int id)
        {
            Loan model = _loansRepository.Get(id);

            return(View(model));
        }