public void Handle(ICommandContext context, AcceptNewSaleCommand command) { var userWalletId = context.Get <User>(command.UserId).GetWalletId(); var offlineStore = context.Get <OfflineStore>(command.AggregateRootId); var storeOwnerWalletId = context.Get <User>(offlineStore.GetOwnerId()).GetWalletId(); offlineStore.AcceptNewSale(storeOwnerWalletId, command.UserId, userWalletId, command.Amount); }
public async Task <BaseApiResponse> AcceptNewSale([FromBody] AcceptNewSaleRequest request) { request.CheckNotNull(nameof(request)); var currentAccount = _contextService.GetCurrentAccount(HttpContext); var command = new AcceptNewSaleCommand(currentAccount.UserId.ToGuid(), request.Amount) { AggregateRootId = request.OfflineStoreId }; var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new BaseApiResponse()); }
public void Handle(ICommandContext context, AcceptNewSaleCommand command) { context.Get <Partner>(command.AggregateRootId).AcceptNewSale(command.Region, command.Amount); }