public async Task <BaseApiResponse> AddCartGoods(AddCartGoodsRequest request) { //获取用户的购物车后台获取 request.CheckNotNull(nameof(request)); TryInitUserModel(); var command = new AddCartGoodsCommand( request.StoreId, request.GoodsId, request.SpecificationId, request.GoodsName, request.GoodsPic, request.SpecificationName, request.Price, request.OriginalPrice, request.Quantity, request.Stock, request.Benevolence) { 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> AddCartGoods(AddCartGoodsRequest request) { //获取用户的购物车后台获取 request.CheckNotNull(nameof(request)); var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current); var userInfo = _userQueryService.FindUser(currentAccount.UserId.ToGuid()); var command = new AddCartGoodsCommand( request.StoreId, request.GoodsId, request.SpecificationId, request.GoodsName, request.GoodsPic, request.SpecificationName, request.Price, request.OriginalPrice, request.Quantity, request.Stock, request.Benevolence) { AggregateRootId = userInfo.CartId }; var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new BaseApiResponse()); }