コード例 #1
0
 public ActionResult updateOptionsOfProduct(int id)
 {
     try
     {
         OptionsOfProduct optionsOfProduct = new OptionsOfProduct();
         Product          product          = productService.GetByPrimaryKey(id);
         if (product != null)
         {
             List <TblOption> options = optionService.GetByProductID(id);
             if (options != null && options.Count > 0)
             {
                 optionsOfProduct.Options = options;
                 for (int i = 0; i < options.Count; i++)
                 {
                     if (!string.IsNullOrEmpty(options[i].OptionValue))
                     {
                         if (i == 0)
                         {
                             optionsOfProduct.Option1Values = options[i].OptionValue.Split(',');
                         }
                         else if (i == 1)
                         {
                             optionsOfProduct.Option2Values = options[i].OptionValue.Split(',');
                         }
                         else if (i == 2)
                         {
                             optionsOfProduct.Option3Values = options[i].OptionValue.Split(',');
                         }
                     }
                 }
             }
         }
         optionsOfProduct.ProductID = id;
         return(View(optionsOfProduct));
     }
     catch (Exception ex)
     {
         LogService.WriteException(ex);
         return(View());
     }
 }
コード例 #2
0
 public ActionResult updateOptionsOfProduct(OptionsOfProduct optionsOfProduct)
 {
     try
     {
         if (optionsOfProduct.Options != null && optionsOfProduct.Options.Count > 0)
         {
             for (int i = 0; i < optionsOfProduct.Options.Count; i++)
             {
                 TblOption option = optionsOfProduct.Options[i];
                 option.Position         = i + 1;
                 option.ModifiedDateTime = SDateTime.GetYYYYMMddHmmSSNow();
                 optionService.Update(option);
             }
         }
         return(RedirectToAction("detail", "products", new { id = optionsOfProduct.ProductID, strMessage = "1" }));
     }
     catch (Exception ex)
     {
         LogService.WriteException(ex);
     }
     return(RedirectToAction("detail", "products", new { id = optionsOfProduct.ProductID, strMessage = "0" }));
 }