Exemplo n.º 1
0
        public async Task <ResponseModel <AddWalletGroupItemResponseModel> > Handle(AddWalletGroupItemRequestModel requestModel, CancellationToken cancellationToken)
        {
            var walletGroupExists = await walletGroupRepository.GetByIdAsync(requestModel.WalletGroupId) != null;

            if (walletGroupExists == true)
            {
                var walletGroupItemModel = mapper.Map <WalletGroupItemModel>(requestModel);

                walletGroupItemModel.Id = generateIdHelper.Generate();

                var addedId = await walletGroupItemRepository.AddAsync(walletGroupItemModel);

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

            return(responseModel);
        }
Exemplo n.º 2
0
        public async Task <ResponseModel <AddWalletGroupResponseModel> > Handle(AddWalletGroupRequestModel requestModel, CancellationToken cancellationToken)
        {
            var walletGroupModel = mapper.Map <WalletGroupModel>(requestModel);

            walletGroupModel.Id = generateIdHelper.Generate();

            var addedId = await walletGroupRepository.AddAsync(walletGroupModel);

            responseModel = new ResponseModel <AddWalletGroupResponseModel>
            {
                IsValid      = true,
                ErrorMessage = null,
                Data         = new AddWalletGroupResponseModel
                {
                    Id = addedId
                }
            };

            return(responseModel);
        }