示例#1
0
        public async Task <IActionResult> GetTransactionsByStatus([FromQuery] string status)
        {
            var request = new GetTransactionByStatusRequest
            {
                Status = status
            };

            var result = await _mediator.Send(request);

            return(GetResponse(result));
        }
        public async Task <TransactionResponseDataModel <GetTransactionResponseModel> > Handle(GetTransactionByStatusRequest request, CancellationToken cancellationToken)
        {
            var response = new TransactionResponseDataModel <GetTransactionResponseModel>();

            try
            {
                var status = GetStatusByFirstLetter(request.Status);

                var entities = await _repository.GetTransactionByStatusAsync((int)status);

                var transactions = _mapper.Map <IEnumerable <GetTransactionResponseModel> >(entities);

                response.Data       = transactions;
                response.StatusCode = StatusCodes.Status200OK;
            }
            catch (Exception)
            {
                return(new TransactionResponseDataModel <GetTransactionResponseModel>
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }

            return(response);
        }