public async Task <BaseApiResponse> RemoveCartGoods(RemoveCartGoodsRequest request) { request.CheckNotNull(nameof(request)); TryInitUserModel(); var command = new RemoveCartGoodsCommand(request.Id) { AggregateRootId = _user.CartId }; var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new BaseApiResponse()); }
public async Task <BaseApiResponse> RemoveCartGoods(RemoveCartGoodsRequest request) { request.CheckNotNull(nameof(request)); var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current); var userInfo = _userQueryService.FindUser(currentAccount.UserId.ToGuid()); var command = new RemoveCartGoodsCommand(request.Id) { AggregateRootId = userInfo.CartId }; 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, RemoveCartGoodsCommand command) { context.Get <Cart>(command.AggregateRootId).RemoveGoods(command.CartGoodsId); }