Ejemplo n.º 1
0
        public async Task <ResponseModel <GetWalletByIdResponseModel> > Handle(GetWalletByIdRequestModel requestModel, CancellationToken cancellationToken)
        {
            var walletModel = await walletRepository.GetByIdAsync(requestModel.Id);

            var getWalletByIdResponseModel = mapper.Map <GetWalletByIdResponseModel>(walletModel);

            if (getWalletByIdResponseModel != null)
            {
                responseModel = new ResponseModel <GetWalletByIdResponseModel>
                {
                    IsValid      = true,
                    ErrorMessage = null,
                    Data         = getWalletByIdResponseModel
                };
            }
            else
            {
                responseModel = new ResponseModel <GetWalletByIdResponseModel>
                {
                    IsValid      = false,
                    ErrorMessage = "Invalid Wallet Id.",
                    Data         = null
                };
            }

            return(responseModel);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Get([FromRoute] GetWalletByIdRequestModel requestModel)
        {
            var responseModel = await mediator.Send(requestModel);

            if (responseModel.IsValid)
            {
                return(Ok(responseModel));
            }
            else
            {
                return(BadRequest(responseModel));
            }
        }