Beispiel #1
0
 public ActionResult SaveBannerManager(List <BannerItem> AddArr, List <BannerItem> EditArr, List <BannerItem> DelArr)
 {
     if (AddArr != null)
     {
         foreach (BannerItem item in AddArr)
         {
             BannerItem tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             db.BannerItems.Add(tmpObj);
         }
     }
     if (EditArr != null)
     {
         foreach (BannerItem item in EditArr)
         {
             BannerItem tmpObj = item;
             //奇怪,传进来的明明是""但是在后台获取就是null,只能做转换了
             PubFunction.NotNullObj(ref tmpObj);
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == tmpObj.BIID);
             //tmpItem.Description = tmpObj.Description;
             //tmpItem.HrefPath = tmpObj.HrefPath;
             //tmpItem.ImgPath = tmpObj.ImgPath;
             //tmpItem.Index = tmpObj.Index;
             //tmpItem.Title = tmpObj.Title;
             PubFunction.CopyObj(tmpObj, ref tmpItem);
         }
     }
     if (DelArr != null)
     {
         foreach (BannerItem item in DelArr)
         {
             BannerItem tmpItem = db.BannerItems.FirstOrDefault(r => r.BIID == item.BIID);
             if (tmpItem != null)
             {
                 db.BannerItems.Remove(tmpItem);
             }
         }
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }
Beispiel #2
0
 public ActionResult SaveColumnManager(List <Column> AddArr, List <Column> EditArr, List <Column> DelArr)
 {
     if (AddArr != null)
     {
         foreach (Column item in AddArr)
         {
             Column tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             db.Columns.Add(tmpObj);
         }
     }
     if (EditArr != null)
     {
         foreach (Column item in EditArr)
         {
             Column tmpObj = item;
             PubFunction.NotNullObj(ref tmpObj);
             Column tmpItem = db.Columns.FirstOrDefault(r => r.ColumnID == tmpObj.ColumnID);
             PubFunction.CopyObj(tmpObj, ref tmpItem);
         }
     }
     if (DelArr != null)
     {
         foreach (Column item in DelArr)
         {
             Column tmpItem = db.Columns.FirstOrDefault(r => r.ColumnID == item.ColumnID);
             if (tmpItem != null)
             {
                 db.Columns.Remove(tmpItem);
             }
         }
     }
     db.SaveChanges();
     if (Request.IsAjaxRequest())
     {
         string jsonStr = PubFunction.BuildResult("OK");
         return(Content(jsonStr));
     }
     else
     {
         return(View());
     }
 }