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

            if (walletModel != null)
            {
                await walletRepository.DeleteAsync(walletModel);

                responseModel = new ResponseModel <DeleteWalletResponseModel>
                {
                    IsValid      = true,
                    ErrorMessage = null,
                    Data         = null
                };
            }
            else
            {
                responseModel = new ResponseModel <DeleteWalletResponseModel>
                {
                    IsValid      = false,
                    ErrorMessage = "Invalid Wallet Id.",
                    Data         = null
                };
            }

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

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