Пример #1
0
 public IActionResult SaveProductDescription(string description, int productId)
 {
     if (productId > 0)
     {
         ProductInformation product = _productInformationService.GetProductById(productId);
         product.Description = description;
         _productInformationService.UpdateProduct(product);
     }
     return(View());
 }
Пример #2
0
 public IActionResult SaveProduct()
 {
     try
     {
         int id = Request.Form["Id"].TryToInt(0);
         if (id > 0)
         {
             var info = _productInformationService.GetProductById(id);
             info.ProductCode   = Request.Form["ProductCode"].TryToString();
             info.ProductName   = Request.Form["ProductName"].TryToString();
             info.BatchId       = Request.Form["BatchId"].TryToInt(0);
             info.Type          = (ClassTypeEnum)Request.Form["ClassType"].TryToInt(0);
             info.ProductStatus = (ProductStatusTypeEnum)Request.Form["ProductStatusType"].TryToInt(0);
             info.StockType     = (StockStatusTypeEnum)Request.Form["StockStatusType"].TryToInt(0);
             _productInformationService.UpdateProduct(info);
             return(Json(new { code = 1, msg = "OK", id = info.Id }));
         }
         else
         {
             ProductInformation productInfo = new ProductInformation();
             productInfo.ProductCode   = Request.Form["ProductCode"].TryToString();
             productInfo.ProductName   = Request.Form["ProductName"].TryToString();
             productInfo.BatchId       = Request.Form["BatchId"].TryToInt(0);
             productInfo.Type          = (ClassTypeEnum)Request.Form["ClassType"].TryToInt(0);
             productInfo.ProductStatus = (ProductStatusTypeEnum)Request.Form["ProductStatusType"].TryToInt(0);
             productInfo.StockType     = (StockStatusTypeEnum)Request.Form["StockStatusType"].TryToInt(0);
             id = _productInformationService.AddProduct(productInfo);
             if (id > 0)
             {
                 return(Json(new { code = 1, msg = "OK", id = id }));
             }
             else
             {
                 return(Json(new { code = 0, msg = "保存失败" }));
             }
         }
     }
     catch (Exception ex)
     {
         return(Json(new { code = 0, msg = ex.Message }));
     }
 }