コード例 #1
0
 private OperationViewModel MapInternal(Operation operation, IRequestContextReader context)
 {
     return(new OperationViewModel()
     {
         AccountKey = operation.AccountKey,
         Amount = operation.Amount,
         Id = operation.Id,
         Transaction = _transactionMapper.Map(operation.Transaction, context)
     });
 }
コード例 #2
0
 private AccountViewModel MapInternal(Account account, IRequestContextReader context)
 {
     return(new AccountViewModel()
     {
         CurrentAmount = account.CurrentSituation.CurrentAmount,
         InitialAmount = account.CurrentSituation.InitialAmount,
         Key = account.Key,
         StartDate = account.CurrentSituation.StartDate,
         Operations = account.CurrentSituation.Operations.Select(o => _operationMapper.Map(o, context))
     });
 }
コード例 #3
0
        /// <summary>
        /// Main service method that facilitates the postal code taxes retrieval request
        /// </summary>
        /// <returns>PostalCodeTaxResponse</returns>
        public async Task <PostalCodeTaxResponse> ListAsync()
        {
            try
            {
                var postalCodeTaxes = await _postalCodeTaxRepository.ListAsync();

                var response = _responseMapper.Map(postalCodeTaxes);

                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Error while trying to retrieve a list of postal codes with their corresponding tax calculation types.");

                // rethrow to preserve stack details
                throw;
            }
        }
コード例 #4
0
        public async Task <IEnumerable <IHttpMessageResponse> > DeleteMessage(IEnumerable <string> ids)
        {
            try
            {
                var deleteMessageBatchRequest = BuildDeleteMessageBatchRequest(ids);
                var deleteMessageResponse     = await DeleteMessageBatchAsync(deleteMessageBatchRequest);

                Console.WriteLine($"SQS Delete Response: {deleteMessageResponse.HttpStatusCode}");
                var sqsSendMessageResponse = _sqsDeleteResponseMapper.Map(deleteMessageResponse);
                return(sqsSendMessageResponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not delete message.");
                HandleError(ex);
            }

            return(new List <SqsSendMessageResponse>());
        }
コード例 #5
0
        public async Task <IEnumerable <IHttpMessageResponse> > SendMessage(IEnumerable <object> payloads)
        {
            try
            {
                var sendMessageBatchRequest  = BuildSendMessageBatchRequest(payloads);
                var sendMessageBatchResponse = await SendMessageBatchAsync(sendMessageBatchRequest);

                Console.WriteLine($"SQS Batch Send Result: Failed = {sendMessageBatchResponse.Failed.Count}, Success = {sendMessageBatchResponse.Successful.Count}");
                var sqsSendMessageResponse = _sqsSendResponseMapper.Map(sendMessageBatchResponse);
                return(sqsSendMessageResponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not send batch payload.");
                HandleError(ex);
            }

            return(new List <SqsSendMessageResponse>());
        }
コード例 #6
0
        public async Task <IHttpMessageResponse> DeleteMessage(string id)
        {
            try
            {
                var deleteMessageRequest = new DeleteMessageRequest {
                    QueueUrl = _queueUrl, ReceiptHandle = id
                };
                var deleteMessageResponse = await DeleteMessageAsync(deleteMessageRequest);

                Console.WriteLine($"SQS Delete Response: {deleteMessageResponse.HttpStatusCode}");
                var sqsSendMessageResponse = _sqsDeleteResponseMapper.Map(deleteMessageResponse);
                return(sqsSendMessageResponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not delete message.");
                HandleError(ex);
            }

            return(new SqsSendMessageResponse());
        }
コード例 #7
0
        public virtual async Task <IActionResult> Handle(HttpRequest httpRequest, ModelStateDictionary modelState, IViewArgument <TIntent> viewArgument)
        {
            if (modelState.IsValid)
            {
                EnrichContext(_contextHolder.Context, httpRequest);

                var intent = viewArgument.Map(_contextHolder.Context);
                var result = await ProcessRequest(intent);

                if (result.IsSuccessful)
                {
                    var mappedViewModel = _responseMapper.Map(result.Content, _contextHolder.Context);
                    return(CreateResponse(httpRequest, mappedViewModel));
                }
                return(CreateErrorResponse(httpRequest, result));
            }
            else
            {
                var result = modelState.ToErrorResult <TOutput>();
                return(CreateValidationErrorResponse(httpRequest, result));
            }
        }
コード例 #8
0
        public async Task <IHttpMessageResponse> SendMessage(object payload)
        {
            try
            {
                var jsonPayload        = payload.ToJson();
                var sendMessageRequest = new SendMessageRequest {
                    QueueUrl = _queueUrl, MessageBody = jsonPayload
                };
                var sendMessageResponse = await SendMessageAsync(sendMessageRequest);

                Console.WriteLine($"SQS Send Message ID: {sendMessageResponse.MessageId}");
                var sqsSendMessageResponse = _sqsSendResponseMapper.Map(sendMessageResponse);
                return(sqsSendMessageResponse);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not send payload.");
                HandleError(ex);
            }

            return(new SqsSendMessageResponse {
                MessageId = string.Empty
            });
        }