コード例 #1
0
 public ActionResult Show(int? id) {
     vId = id ?? 0;
     using (club = new ClubEntities()) {
         article = club.Articles.Where(v => v.Id == vId).FirstOrDefault();
     }
     return View("~/areas/bwum/views/contribute/show.cshtml", article);
 }
コード例 #2
0
 public JsonResult Del(int? id) { 
     vId = id ?? 0;
     hitStr = "系统异常,操作失败!";
     using (club = new ClubEntities()) {
         article = club.Articles.Where(v=> v.Id == vId).FirstOrDefault();
         if (article != null){
             club.Articles.Remove(article);
             if (club.SaveChanges() >= 0){
                 hitStr = "删除成功!";
                 status = Status.success;
             }
         }    
     }
     return Json(new { status = status.ToString(), content = HtmlCommon.GetHitStr(hitStr, status) });
 }
コード例 #3
0
 public JsonResult MultiDel(string[] chk) { 
     if (chk.Length == 0) {
         hitStr = "未选中行,请选中行后再进行操作!";
     }else{
         using (club = new ClubEntities()) { 
              foreach (string ck in chk) {
                  vId = Convert.ToInt32(ck);
                  article = club.Articles.Where(v => v.Id == vId).FirstOrDefault();
                  if (article != null)
                  {
                      club.Articles.Remove(article);
                  }
             }
              if (club.SaveChanges() >= 0) {
                  hitStr = "删除成功!";
                  status = Status.success;
              }else{
                  hitStr = "系统异常删除失败,请稍后重试!";
              }
         }               
     }
     return Json(new { state=status.ToString(),context=hitStr.ToString(),url="/bwum/Contribute/"});
 }
コード例 #4
0
 public ActionResult SetCheck(int? id,string title,string context,string tags) {
     vId=id??0;
     StringBuilder str = new StringBuilder();
     Tag tag = new Tag();
     using (club = new ClubEntities()) {
         article = club.Articles.Where(t => t.Id == vId).FirstOrDefault();
         if (article != null) {
             article.Tags = tags;
             article.TagIds =App_Start.CommonMethod.SetTags(club, tags);
             if (article.Status == 1)
                 article.Status = 0;
             else
                 article.Status = 1;
             if (club.SaveChanges() >= 0) {
                 hitStr = "状态修改成功!";
                 status = Status.success;
             }
             else {
                 hitStr = "系统异常,请稍后重试!";
             }
         }
         else
         {
             return RedirectToAction("notfound","error");
         }
     }
     ViewBag.StatusStr = HtmlCommon.GetHitStr(hitStr, status);
     return View("~/areas/bwum/views/contribute/show.cshtml", article);
 } 
コード例 #5
0
 private bool SetStatus(string[] chks,int sId) {
     using (club = new ClubEntities()) {
          Article article= new Article();
         int aId=0;
         foreach (string chk in chks) {
            aId=Convert.ToInt32(chk);
            article = club.Articles.Where(a => a.Id == aId).FirstOrDefault();
            article.Status = (byte)sId;
            if (club.SaveChanges()< 0)
                return false;
         }
         return true;
     }
 }