예제 #1
0
        public IActionResult Edit(int?id)
        {
            ProductInformationViewModel model = new ProductInformationViewModel();

            //编辑界面
            if (id != null)
            {
                ProductInformation product = _productInformationService.GetProductById((int)id);
                model = new ProductInformationViewModel
                {
                    ProductId         = product.Id,
                    ProductCode       = product.ProductCode,
                    ProductName       = product.ProductName,
                    ProductStatusType = product.ProductStatus,
                    StockStatusType   = product.StockType,
                    ClassType         = product.Type,
                    Description       = product.Description,
                    BatchId           = product.BatchId
                };
            }
            PopulateClassDropDownList();
            PopulateProductStatusDropDownList();
            PopulateStockStatusDropDownList();
            PopulateBatchDropDownList();
            return(View(model));
        }
예제 #2
0
        public ResponseOutput GetProductDetailByProductId(int productId)
        {
            try
            {
                _logger.LogInformation("进入GetProductDetailByProductId方法");
                ProductInformation product = _productService.GetProductById(productId);
                //图片详情
                var productDetails = _productDetailService.GetDetailsByProductId(product.Id);
                List <ProductDetailOutputDto> detailDtos = new List <ProductDetailOutputDto>();
                if (productDetails != null)
                {
                    foreach (var productDetail in productDetails)
                    {
                        detailDtos.Add(new ProductDetailOutputDto()
                        {
                            PhotoPath = productDetail.PhotoPath.Replace('\\', '/')
                        });
                    }
                }

                ProductDto dto = new ProductDto();
                dto.Id   = product.Id;
                dto.Code = product.ProductCode;
                dto.Name = product.ProductName;
                if (!string.IsNullOrEmpty(product.Description))
                {
                    //修改富文本的图片为绝对路径
                    string processDescription = TextParse.ProcessHtmlImageUrlList(product.Description);
                    dto.Description = processDescription;
                }
                dto.ClassType     = (int)product.Type;
                dto.StockStatus   = (int)product.StockType;
                dto.ProductStatus = (int)product.ProductStatus;
                dto.Photos        = detailDtos.Select(item => Path.Combine("http://www.bangbangfuli.cn:5001/", item.PhotoPath.Replace('\\', '/'))).ToList();

                return(new ResponseOutput(dto, "0", string.Empty, HttpContext.TraceIdentifier));
            }
            catch (Exception ex)
            {
                _logger.LogError($"异常为{ex.ToString()}");
                return(new ResponseOutput(null, "-1", ex.Message, HttpContext.TraceIdentifier));
            }
        }
예제 #3
0
        public ResponseOutput GetProductDetailByProductId(int productId)
        {
            try
            {
                _logger.LogInformation("进入GetProductDetailByProductId方法");
                ProductInformation product = _productService.GetProductById(productId);
                //图片详情
                var productDetails = _productDetailService.GetDetailsByProductId(product.Id);
                List <ProductDetailOutputDto> detailDtos = new List <ProductDetailOutputDto>();
                if (productDetails != null)
                {
                    foreach (var productDetail in productDetails)
                    {
                        detailDtos.Add(new ProductDetailOutputDto()
                        {
                            PhotoPath = productDetail.PhotoPath
                        });
                    }
                }

                ProductDto dto = new ProductDto
                {
                    Code          = product.ProductCode,
                    Name          = product.ProductName,
                    Description   = product.Description,
                    ClassType     = (int)product.Type,
                    StockStatus   = (int)product.StockType,
                    ProductStatus = (int)product.ProductStatus,
                    Photos        = detailDtos.Select(item => item.PhotoPath).ToList()
                };
                return(new ResponseOutput(dto, "0", string.Empty, HttpContext.TraceIdentifier));
            }
            catch (Exception ex)
            {
                _logger.LogError($"异常为{ex.ToString()}");
                return(new ResponseOutput(null, "-1", ex.Message, HttpContext.TraceIdentifier));
            }
        }
예제 #4
0
        /// <summary>
        /// 新建商品页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult AddNewProduct(int id)
        {
            ProductInformation productInfo = new ProductInformation();

            if (id > 0)
            {
                productInfo = _productInformationService.GetProductById(id);
            }
            List <BatchInformation> batchInfos = _batchInformationService.GetAll();

            ViewBag.BatchInfos = batchInfos;
            return(View(productInfo));
        }