public void Handle(ICommandContext context, StoreUpdateGoodsCommand command) { context.Get <Goods>(command.AggregateRootId).Update( command.CategoryIds, new GoodsStoreEditableInfo( command.Name, command.Description, command.Pics, command.Price, command.OriginalPrice, command.Stock, command.IsPayOnDelivery, command.IsInvoice, command.Is7SalesReturn, command.Sort)); }
public async Task <BaseApiResponse> StoreUpdateGoods(AddGoodsRequest request) { request.CheckNotNull(nameof(request)); TryInitUserModel(); var command = new StoreUpdateGoodsCommand( request.CategoryIds, request.Name, request.Description, request.Pics, request.Price, request.OriginalPrice, request.Stock, request.IsPayOnDelivery, request.IsInvoice, request.Is7SalesReturn, request.Sort) { AggregateRootId = request.Id }; var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } //更新默认规格 var specification = _goodsQueryService.GetGoodsDefaultSpecification(request.Id); if (specification != null) { var thumb = specification.Thumb; if (request.Pics.Any()) { thumb = request.Pics[0]; } //更新默认规格 var command2 = new UpdateSpecificationCommand( request.Id, specification.Id, "默认规格", "默认规格", thumb, request.Price, request.OriginalPrice, request.OriginalPrice / 100M, "", "", request.Stock); var result2 = await ExecuteCommandAsync(command2); if (!result2.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } } return(new BaseApiResponse()); }