示例#1
0
 public JsonResult GetCaseEdit(BA_Case result)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var m = from t in db.BA_Case
                 where t.Name == result.Name && t.Id != result.Id
                 select t;
         if (m.Count() > 0)
         {
             return(Json(new { data = "fail", content = "案例名称重复!" }));
         }
         var BA_Case    = from t in db.BA_Case where t.Id == result.Id select t;
         var resultInfo = BA_Case.FirstOrDefault();
         resultInfo.Name       = result.Name;
         resultInfo.SubName    = result.SubName;
         resultInfo.Icon       = result.Icon;
         resultInfo.Background = result.Background;
         resultInfo.Image      = result.Image;
         resultInfo.ToUrl      = result.ToUrl;
         resultInfo.Content    = result.Content;
         resultInfo.Status     = result.Status;
         resultInfo.AddUser    = BasePage.GetCookie("UserNameCookie");
         resultInfo.AddTime    = DateTime.Now;
         db.SaveChanges();
         return(Json(new { data = "success", content = "修改案例成功!" }));
     }
 }
示例#2
0
 public JsonResult GetCaseAdd(BA_Case result)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var m = from t in db.BA_Case
                 where t.Name == result.Name
                 select t;
         if (m.Count() > 0)
         {
             return(Json(new { data = "fail", content = "案例名称重复!" }));
         }
         result.AddUser = BasePage.GetCookie("UserNameCookie");
         result.AddTime = DateTime.Now;
         db.BA_Case.Add(result);
         db.SaveChanges();
         return(Json(new { data = "success", content = "新增案例成功!" }));
     }
 }