Beispiel #1
0
        public async Task <BaseApiResponse> GoodsUnPublish(InfoRequest request)
        {
            request.CheckNotNull(nameof(request));
            var goodsAlis = _goodsQueryService.GetGoodsAlias(request.Id);

            if (goodsAlis == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "未找到商品"
                });
            }
            var command = new UnpublishGoodsCommand
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Beispiel #2
0
        public async Task <BaseApiResponse> UnPublish(PublishRequest request)
        {
            request.CheckNotNull(nameof(request));
            var goods = _goodsQueryService.GetGoodsAlias(request.Id);

            if (goods == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "未找到商品"
                });
            }
            var command = new UnpublishGoodsCommand
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "下架商品", request.Id, goods.Name);
            return(new BaseApiResponse());
        }
Beispiel #3
0
        public async Task <BaseApiResponse> UnPublish(PublishRequest request)
        {
            request.CheckNotNull(nameof(request));
            var command = new UnpublishGoodsCommand
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Beispiel #4
0
 public void Handle(ICommandContext context, UnpublishGoodsCommand command)
 {
     context.Get <Goods>(command.AggregateRootId).Unpublish();
 }