public async Task <BaseApiResponse> AddGoods(AddGoodsRequest request) { request.CheckNotNull(nameof(request)); TryInitUserModel(); //创建商品 var goodsId = GuidUtil.NewSequentialId(); var command = new CreateGoodsCommand( goodsId, request.StoreId, request.CategoryIds, request.Name, request.Description, request.Pics, request.Price, request.OriginalPrice, request.Stock, request.IsPayOnDelivery, request.IsInvoice, request.Is7SalesReturn, request.Sort); var result = await ExecuteCommandAsync(command); if (!result.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } //初始化默认规格 var thumb = ""; if (request.Pics.Any()) { thumb = request.Pics[0]; } var command2 = new AddSpecificationCommand( goodsId, "默认规格", "默认规格", thumb, request.Price, request.Stock, request.OriginalPrice, request.OriginalPrice / 100M, "", ""); var result2 = await ExecuteCommandAsync(command2); if (!result2.IsSuccess()) { return(new BaseApiResponse { Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage()) }); } return(new AddGoodsResponse { GoodsId = goodsId }); }
public void Handle(ICommandContext context, AddSpecificationCommand command) { context.Get <Goods>(command.AggregateRootId).AddSpecification( new Domain.Models.Goodses.Specifications.SpecificationInfo( command.Name, command.Value, command.Thumb, command.Price, command.OriginalPrice, command.Benevolence, command.Number, command.BarCode ), command.Stock); }
private void HandleCreateSpecificationRequest(object sender, SpecificationEventArgs e) { var testProjectname = string.Format("{0}.Tests", e.Source.Item.ContainingProject.Name); var targetProject = FindProject(dte.Solution.Projects.Cast <Project>(), testProjectname); if (targetProject == null) { MessageBox.Show(string.Format("You need create a test project {0} first.", testProjectname)); //var specitem = targetProject.ProjectItems.AddFromTemplate(e.SpecName, e.SpecName); //var w = specitem.Open(Constants.vsViewKindCode); //w.Visible = true; return; } e.targetProject = targetProject; if (addSpecificationCommand == null) { addSpecificationCommand = new AddSpecificationCommand(dte); } addSpecificationCommand.Execute(e); }