コード例 #1
0
            public async Task <ResponseResult> Handle(Command request, CancellationToken cancellationToken)
            {
                if (string.IsNullOrWhiteSpace(request.Id))
                {
                    return(ResponseResult.Error($"标识Id: {request.Id} 不能为空."));
                }

                request.Id = request.Id.Trim();

                using (var scope = _databaseScopeFactory.CreateWithTransaction())
                {
                    if (await _productInfoRepository.IsReleaseAsync(request.Id))
                    {
                        return(ResponseResult.Error($"发布状态不不允许删除."));
                    }

                    await _productInfoRepository.DeleteAsync(request.Id, request.UserId);

                    scope.SaveChanges();
                }

                return(ResponseResult.Ok());
            }