Beispiel #1
0
 public void Handle(ICommandContext context, AddBankCardCommand command)
 {
     context.Get <Wallet>(command.AggregateRootId).AddBankCard(new BankCardInfo(
                                                                   command.BankName,
                                                                   command.OwnerName,
                                                                   command.Number));
 }
        public static AddBankCardCommand ToAddBankCardCommand(this BankCardViewModel bankcardViewModel)
        {
            var command = new AddBankCardCommand(
                bankcardViewModel.WalletId,
                bankcardViewModel.BankName,
                bankcardViewModel.OwnerName,
                bankcardViewModel.Number);

            return(command);
        }
Beispiel #3
0
        public async Task <BaseApiResponse> AddBankCard(AddBankCardRequest request)
        {
            request.CheckNotNull(nameof(request));

            var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current);

            var command = new AddBankCardCommand(
                currentAccount.WalletId.ToGuid(),
                request.BankName,
                request.OwnerName,
                request.Number);

            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }