예제 #1
0
            private async Task <(string productid, string errorMsg)> AddProductInfoAfterGetId(Command request, CancellationToken cancellationToken)
            {
                string productId = string.Empty;
                string errorMsg  = string.Empty;

                using (var scope = _databaseScopeFactory.CreateWithTransaction())
                {
                    if (await _productInfoRepository.HasProductFullNameAsync(request.ProdFullName))
                    {
                        errorMsg = $"产品全称:{request.ProdFullName} 已存在.";
                        return(productId, errorMsg);
                    }

                    string currentmaxCode = await _productInfoRepository.GetMaxProductCodeAsync();

                    QueryStack.Models.ProductInfo entity = new QueryStack.Models.ProductInfo()
                    {
                        ProdCode     = Lunz.ProductCenter.Common.FormatDataCode.GetNewLoacalCode("CP", currentmaxCode),
                        ProdName     = request.ProdName,
                        ProdFullName = request.ProdFullName,
                        ProdTypeId   = request.ProdTypeId,
                        ProdTypeCode = request.ProdTypeCode,
                        ProdTypeName = request.ProdTypeName,
                    };
                    await _productInfoRepository.AddAsync(entity, request.UserId);

                    scope.SaveChanges();

                    var newedProductInfo = _productInfoRepository.FindByProductFullNameAsync(request.ProdFullName);
                    if (newedProductInfo == null || newedProductInfo.Result == null)
                    {
                        errorMsg = $"产品:{request.ProdFullName} 保存异常.";
                        return(productId, errorMsg);
                    }

                    productId = newedProductInfo.Result.Id.ToString();
                }

                return(productId, errorMsg);
            }
예제 #2
0
            private async Task <string> UpdateProduct(Command request)
            {
                string errorMsg = string.Empty;

                if (await _productInfoRepository.HasProductFullNameAsync(request.ProdFullName, request.Id))
                {
                    errorMsg = $"产品全称:{request.ProdFullName} 已存在.";
                    return(errorMsg);
                }

                QueryStack.Models.ProductInfo entity = new QueryStack.Models.ProductInfo()
                {
                    Id           = request.Id,
                    ProdName     = request.ProdName,
                    ProdFullName = request.ProdFullName,
                    ProdTypeId   = request.ProdTypeId,
                    ProdTypeCode = request.ProdTypeCode,
                    ProdTypeName = request.ProdTypeName,
                };
                await _productInfoRepository.UpdateAsync(entity, request.UserId);

                return(errorMsg);
            }
예제 #3
0
 public Response(QueryStack.Models.ProductInfo data)
 {
     Data = data;
 }