public ActionResult eayup(bool ko, string id) { try { using (BlognEntities blog = new BlognEntities()) { if (id == "" || id == null) { return(Json(new { date = "请输入编号", type = 0 }, JsonRequestBehavior.AllowGet)); } int idd = int.Parse(id); int count = blog.Essay.Where(a => a.esid == idd).ToList().Count(); if (count == 0) { return(Json(new { date = "没有此编号的文章哦", type = 0 }, JsonRequestBehavior.AllowGet)); } Essay es = blog.Essay.Where(a => a.esid == idd).FirstOrDefault(); es.eisno = ko; blog.SaveChanges(); return(Json(new { date = "已修改", type = 1, isno = es.eisno }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { date = "保存出错,原因是:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
//添加相册 public ActionResult photoadd(string title, string back) { try { using (BlognEntities blog = new BlognEntities()) { if (title == "" || back == "") { return(Json(new { date = "请填写完整", type = 0 }, JsonRequestBehavior.AllowGet)); } int count = blog.Phabum.Where(a => a.phtitle == title).ToList().Count(); if (count > 0) { return(Json(new { date = "相册已经存在", type = 0 }, JsonRequestBehavior.AllowGet)); } //创建文件夹 string filePhysicalPath = Server.MapPath("~/images/" + title + "/"); if (!Directory.Exists(filePhysicalPath)) //判断上传文件夹是否存在,若不存在,则创建 { Directory.CreateDirectory(filePhysicalPath); //创建文件夹 } Phabum plu = new Phabum(); plu.phtitle = title; plu.phback = back; plu.phdate = DateTime.Now; blog.Phabum.Add(plu); blog.SaveChanges(); return(Json(new { date = "请填写完整", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { date = "保存出错,原因是:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
//文章详情 public ActionResult Essays(string id) { using (BlognEntities blog = new BlognEntities()) { if (id == "" || id == null) { return(Redirect("/Blogback/Essay")); } else { int idd = int.Parse(id); var essay = blog.Essay.Where(a => a.esid == idd).FirstOrDefault(); if (essay == null) { return(Redirect("/Blogback/Essay")); } //文章 ViewData["ess"] = essay; //评论 var dis = blog.Discuss.Where(a => a.esid == essay.esid).ToList(); List <essayus> esus = new List <essayus>(); foreach (var item in dis) { int uid = item.usid; var usd = blog.Usersd.Where(a => a.usid == uid).FirstOrDefault(); essayus esu = new essayus(); esu.dis = item; esu.us = usd; esus.Add(esu); } ViewData["essya"] = esus; } } return(View()); }
/// <summary> /// 添加留言 /// </summary> /// <returns></returns> public ActionResult messageadd(string count) { try { if (Session["name"] == null || Session["name"].ToString() == "") { return(Json(new { data = "请先登录", type = 0 }, JsonRequestBehavior.AllowGet)); } using (BlognEntities blog = new BlognEntities()) { var name = Session["name"].ToString(); var user = blog.Usersd.Where(a => a.usname == name).FirstOrDefault(); int uid = user.usid; //评论 Message dis = new Message(); dis.meconter = count; dis.mesdate = DateTime.Now; dis.usid = uid; blog.Message.Add(dis); blog.SaveChanges(); return(Json(new { data = "已评论", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "评论失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult esdisde(string idd) { try { using (BlognEntities blog = new BlognEntities()) { if (idd == null || idd == "") { return(Json(new { data = "没有相应的编号", type = 0 }, JsonRequestBehavior.AllowGet)); } else { int id = int.Parse(idd); var ph = blog.Discuss.Where(a => a.diid == id).FirstOrDefault(); blog.Discuss.Remove(ph); blog.SaveChanges(); return(Json(new { data = "已删除", type = 1 }, JsonRequestBehavior.AllowGet)); } } } catch (Exception e) { return(Json(new { data = "删除失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult eayadd(string title, string titcount, bool ko) { try { using (BlognEntities blog = new BlognEntities()) { if (title == "" || titcount == "") { return(Json(new { date = "请填写完整", type = 0 }, JsonRequestBehavior.AllowGet)); } int count = blog.Essay.Where(a => a.estitle == title).ToList().Count(); if (count > 0) { return(Json(new { date = "文章名已经存在", type = 0 }, JsonRequestBehavior.AllowGet)); } Essay es = new Essay(); es.estitle = title; es.esconter = titcount; es.esdate = DateTime.Now; es.eisno = ko; blog.Essay.Add(es); blog.SaveChanges(); return(Json(new { date = "已添加", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { date = "保存出错,原因是:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
//文章布局页 public ActionResult Essaying(string title, string fen = "1") { using (BlognEntities blog = new BlognEntities()) { var essay = blog.Essay.ToList(); if (title != "" || title != null) { essay = blog.Essay.Where(a => a.estitle.Contains(title)).ToList(); if (essay.Count() == 0) { essay = blog.Essay.ToList(); } } int t = essay.Count(); int p = int.Parse(fen); if (t > 0) { if (p <= 1) { essay = essay.Take(8).ToList(); } else { essay = essay.Skip((p - 1) * 8).Take(8).ToList(); } } ViewData["ess"] = essay; } return(View()); }
/// <summary> /// 邮箱登录 /// </summary> public ActionResult Logeemal() { try { using (BlognEntities blo = new BlognEntities()) { //验证码 var codes = Request.Form["logcod"].ToString(); var code = Session["code"].ToString(); if (code.ToLower() != codes.ToLower()) { return(Json(new { data = "验证码错误", type = 0 }, JsonRequestBehavior.AllowGet)); } //邮箱 var logemal = Request.Form["logemal"].ToString(); var us = blo.Usersd.Where(a => a.usemal == logemal).FirstOrDefault(); if (us == null) { return(Json(new { data = "该邮箱还没有注册哦", type = 0 }, JsonRequestBehavior.AllowGet)); } Session["name"] = us.usname; Session["img"] = us.uspic; Session["phone"] = us.usphono; return(Json(new { data = "登陆成功", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "登录失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 密码登录 /// </summary> public ActionResult Logen() { try { using (BlognEntities blo = new BlognEntities()) { //手机号 var phone = Request.Form["logphone"].ToString(); //密码 var pwd = Request.Form["logpwd"].ToString(); var us = blo.Usersd.Where(a => a.usphono == phone).FirstOrDefault(); if (us == null) { return(Json(new { data = "请先注册", type = 0 }, JsonRequestBehavior.AllowGet)); } us = blo.Usersd.Where(a => a.usphono == phone && a.uspwd == pwd).FirstOrDefault(); if (us == null) { return(Json(new { data = "密码错误", type = 0 }, JsonRequestBehavior.AllowGet)); } Session["name"] = us.usname; Session["img"] = us.uspic; Session["phone"] = us.usphono; return(Json(new { data = "登陆成功", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "登录失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
//相册布局页 public ActionResult photos(string str, string fen = "1") { using (BlognEntities blog = new BlognEntities()) { var photo = blog.Phabum.ToList(); if (str != "" && str != null) { photo = photo.Where(a => a.phtitle.Contains(str)).ToList(); if (photo.Count() == 0) { photo = blog.Phabum.ToList(); } } int t = photo.Count(); int p = int.Parse(fen); if (t > 0) { if (p <= 1) { photo = photo.Take(8).ToList(); } else { photo = photo.Skip((p - 1) * 8).Take(8).ToList(); } } ViewData["Phabum"] = photo; } return(View()); }
//用户管理布局页 public ActionResult users(string title, string fen = "1") { using (BlognEntities blog = new BlognEntities()) { var us = blog.Usersd.ToList(); if (title != "" || title != null) { us = blog.Usersd.Where(a => a.usname.Contains(title)).ToList(); if (us.Count() == 0) { us = blog.Usersd.ToList(); } } int t = us.Count(); int p = int.Parse(fen); if (t > 0) { if (p <= 1) { us = us.Take(8).ToList(); } else { us = us.Skip((p - 1) * 8).Take(8).ToList(); } } ViewData["user"] = us; } return(View()); }
//留言布局页 public ActionResult messages(string fen = "1") { using (BlognEntities blog = new BlognEntities()) { var mess = blog.Message.ToList(); List <messeus> mu = new List <messeus>(); foreach (var item in mess) { var m = new messeus(); m.messages = item; int id = item.usid; var us = blog.Usersd.Where(a => a.usid == id).FirstOrDefault(); m.users = us; mu.Add(m); } int t = mu.Count(); int p = int.Parse(fen); if (t > 0) { if (p <= 1) { mu = mu.Take(5).ToList(); } else { mu = mu.Skip((p - 1) * 5).Take(5).ToList(); } } ViewData["mess"] = mu; } return(View()); }
//用户管理 public ActionResult user() { using (BlognEntities blog = new BlognEntities()) { var us = blog.Usersd.ToList(); ViewData["user"] = us; } return(View()); }
/// <summary> /// 个人界面 /// </summary> /// <returns></returns> public ActionResult users() { if (Session["name"] == null || Session["name"].ToString() == "") { return(Redirect("/Bloging/Index")); } using (BlognEntities blog = new BlognEntities()) { var name = Session["name"].ToString(); var user = blog.Usersd.Where(a => a.usname == name).FirstOrDefault(); ViewData["userd"] = user; return(View()); } }
//文章评论点赞 public ActionResult plikead(string idd) { try { if (idd == null || idd == "") { return(Json(new { data = "编号不能为空", type = 0 }, JsonRequestBehavior.AllowGet)); } if (Session["name"] == null || Session["name"].ToString() == "") { return(Json(new { data = "请先登录", type = 0 }, JsonRequestBehavior.AllowGet)); } using (BlognEntities blog = new BlognEntities()) { int id = int.Parse(idd); var name = Session["name"].ToString(); var user = blog.Usersd.Where(a => a.usname == name).FirstOrDefault(); int uid = user.usid; //判断该用户是否点过赞 int i = blog.Pclike.Where(a => a.usid == uid && a.pcid == id).ToList().Count(); if (i > 0) { return(Json(new { data = "您已经点过赞了", type = 0 }, JsonRequestBehavior.AllowGet)); } //评论 Photocuss text = blog.Photocuss.Where(a => a.pcid == id).FirstOrDefault(); if (text == null) { return(Json(new { data = "评论不存在", type = 0 }, JsonRequestBehavior.AllowGet)); } //点赞 var eslike = new Pclike(); eslike.usid = user.usid; eslike.pcid = text.pcid; eslike.plcdate = DateTime.Now; blog.Pclike.Add(eslike); text.pcliang = text.pcliang + 1; blog.SaveChanges(); return(Json(new { data = "谢谢客官", type = 1, liang = text.pcliang }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "点赞失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
//文章 public ActionResult Essay(string title) { using (BlognEntities blog = new BlognEntities()) { var essay = blog.Essay.ToList(); if (title != "" || title != null) { essay = blog.Essay.Where(a => a.estitle.Contains(title)).ToList(); if (essay.Count() == 0) { essay = blog.Essay.ToList(); } } ViewData["ess"] = essay; } return(View()); }
//留言删除 public ActionResult mesdelete(string idd) { using (BlognEntities blog = new BlognEntities()) { if (idd == null || idd == "") { return(Json(new { data = "没有编号", type = 0 }, JsonRequestBehavior.AllowGet)); } else { int id = int.Parse(idd); var ph = blog.Message.Where(a => a.meid == id).FirstOrDefault(); blog.Message.Remove(ph); blog.SaveChanges(); return(Json(new { data = "已删除", type = 1 }, JsonRequestBehavior.AllowGet)); } } }
//相册 public ActionResult photo(string str) { using (BlognEntities blog = new BlognEntities()) { var photo = blog.Phabum.ToList(); if (str != "" && str != null) { photo = photo.Where(a => a.phtitle.Contains(str)).ToList(); if (photo.Count() == 0) { photo = blog.Phabum.ToList(); } } ViewData["Phabum"] = photo; } return(View()); }
//留言 public ActionResult message() { using (BlognEntities blog = new BlognEntities()) { var mess = blog.Message.ToList(); List <messeus> mu = new List <messeus>(); foreach (var item in mess) { var m = new messeus(); m.messages = item; int id = item.usid; var us = blog.Usersd.Where(a => a.usid == id).FirstOrDefault(); m.users = us; mu.Add(m); } ViewData["mess"] = mu; } return(View()); }
/// <summary> /// 留言 /// </summary> /// <returns></returns> public ActionResult message() { using (BlognEntities blog = new BlognEntities()) { List <messeus> mesus = new List <messeus>(); var mes = blog.Message.ToList(); foreach (var item in mes) { messeus me = new messeus(); int uid = item.usid; var us = blog.Usersd.Where(a => a.usid == uid).FirstOrDefault(); me.messages = item; me.users = us; mesus.Add(me); } ViewData["mes"] = mesus; } return(View()); }
/// <summary> /// 相册 /// </summary> /// <returns></returns> public ActionResult share() { using (BlognEntities blog = new BlognEntities()) { var pum = blog.Phabum.ToList(); List <photoimg> photo = new List <photoimg>(); foreach (var item in pum) { photoimg pimg = new photoimg(); var id = item.phid; var img = blog.Photograph.Where(a => a.phid == id).ToList(); pimg.phabums = item; pimg.pimg = img; photo.Add(pimg); } ViewData["pumimg"] = photo; } return(View()); }
/// <summary> /// 添加相册评论 /// </summary> /// <returns></returns> public ActionResult phcsadd(string idd, string count) { try { if (idd == null || idd == "") { return(Json(new { data = "编号不能为空", type = 0 }, JsonRequestBehavior.AllowGet)); } if (Session["name"] == null || Session["name"].ToString() == "") { return(Json(new { data = "请先登录", type = 0 }, JsonRequestBehavior.AllowGet)); } using (BlognEntities blog = new BlognEntities()) { int id = int.Parse(idd); var name = Session["name"].ToString(); var user = blog.Usersd.Where(a => a.usname == name).FirstOrDefault(); int uid = user.usid; //相册 Phabum text = blog.Phabum.Where(a => a.phid == id).FirstOrDefault(); if (text == null) { return(Json(new { data = "相册不存在", type = 0 }, JsonRequestBehavior.AllowGet)); } //评论 Photocuss dis = new Photocuss(); dis.pccount = count; dis.pcdate = DateTime.Now; dis.phid = id; dis.usid = uid; blog.Photocuss.Add(dis); blog.SaveChanges(); return(Json(new { data = "已评论", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "评论失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 相册点赞 /// </summary> /// <returns></returns> public ActionResult photoimgs(string id) { if (id == "" || id == null) { return(Json(new { data = "没有相应的编号", type = 0 }, JsonRequestBehavior.AllowGet)); } var name = Session["name"]; if (name == null || name.ToString() == "") { return(Json(new { data = "请先登录", type = 0 }, JsonRequestBehavior.AllowGet)); } using (BlognEntities blo = new BlognEntities()) { int idd = int.Parse(id); var pum = blo.Phabum.Where(a => a.phid == idd).FirstOrDefault(); if (pum == null) { return(Json(new { data = "没有相应的编号", type = 0 }, JsonRequestBehavior.AllowGet)); } var user = blo.Usersd.Where(a => a.usname == name.ToString()).FirstOrDefault(); int naid = user.usid; //判断用户是否点赞 int uslike = blo.Phlike.Where(a => a.usid == naid && a.phid == idd).ToList().Count(); if (uslike >= 1) { return(Json(new { data = "您已经点过赞喽", type = 0 }, JsonRequestBehavior.AllowGet)); } //添加相册点赞 Phlike phk = new Phlike(); phk.usid = naid; phk.phid = idd; phk.pldate = DateTime.Now; blo.Phlike.Add(phk); //修改相册点击量 pum.phliang = pum.phliang + 1; blo.SaveChanges(); return(Json(new { data = "点赞成功", type = 1, liang = pum.phliang }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 相片 /// </summary> /// <returns></returns> public ActionResult shares(string id) { if (id == "" || id == null) { return(Redirect("/Bloging/share")); } else { using (BlognEntities blo = new BlognEntities()) { int idd = int.Parse(id); photoimg pimg = new photoimg(); var pum = blo.Phabum.Where(a => a.phid == idd).FirstOrDefault(); if (pum == null) { return(Redirect("/Bloging/share")); } var pimgs = blo.Photograph.Where(a => a.phid == idd).ToList(); pimg.phabums = pum; pimg.pimg = pimgs; ViewData["pimgd"] = pimg; //相册评论 List <imgsc> imgus = new List <imgsc>(); var photocs = blo.Photocuss.Where(a => a.phid == idd).ToList(); foreach (var item in photocs) { imgsc imgs = new imgsc(); int pidc = item.usid; var us = blo.Usersd.Where(a => a.usid == pidc).FirstOrDefault(); imgs.ph = item; imgs.us = us; imgus.Add(imgs); } ViewData["pucimg"] = imgus; } } return(View()); }
//保存图片 public ActionResult imgadd(HttpPostedFileBase file, string name, string idd) { try { if (file == null || name == null || name == "") { return(Json(new { data = "请填写完整", type = 0 }, JsonRequestBehavior.AllowGet)); } else { using (BlognEntities blog = new BlognEntities()) { int id = int.Parse(idd); var i = blog.Photograph.Where(a => a.otoname == name && a.phid == id).Count(); if (i > 0) { return(Json(new { data = "这个名称已经有了", type = 0 }, JsonRequestBehavior.AllowGet)); } var hu = name + file.FileName.Substring(file.FileName.LastIndexOf(".")); var kl = blog.Phabum.Where(a => a.phid == id).FirstOrDefault(); var j = Server.MapPath("~/images/" + kl.phtitle + "/") + hu; file.SaveAs(j); Photograph pimg = new Photograph(); pimg.otoname = name; pimg.phid = id; pimg.otodate = DateTime.Now; pimg.photos = hu; blog.Photograph.Add(pimg); blog.SaveChanges(); return(Redirect("/Blogback/photoimg?id=" + idd));; } } } catch (Exception e) { return(Json(new { data = "添加失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 文章 /// </summary> /// <returns></returns> public ActionResult diary(string id) { using (BlognEntities blo = new BlognEntities()) { List <Phabum> ji = blo.Phabum.ToList(); ViewData["photo"] = ji; var text = blo.Essay.ToList(); ViewData["text"] = text; var texts = new Essay(); //文章评论 List <essayus> esyus = new List <essayus>(); if (id != "" && id != null) { int idd = int.Parse(id); texts = blo.Essay.Where(a => a.esid == idd).FirstOrDefault(); } else { texts = blo.Essay.Take(1).FirstOrDefault(); } int eid = texts.esid; List <Discuss> dis = blo.Discuss.Where(a => a.esid == eid).ToList(); foreach (var item in dis) { essayus esuss = new essayus(); esuss.dis = item; int usid = item.usid; var us = blo.Usersd.Where(a => a.usid == usid).FirstOrDefault(); esuss.us = us; esyus.Add(esuss); } ViewData["textx"] = texts; //评论 ViewData["pinglun"] = esyus; } return(View()); }
//删除图片 public ActionResult imgeremove(string idd) { try { using (BlognEntities blog = new BlognEntities()) { if (idd == null || idd == "") { return(Json(new { data = "没有相应的编号", type = 0 }, JsonRequestBehavior.AllowGet)); } else { int id = int.Parse(idd); var ph = blog.Photograph.Where(a => a.otoid == id).FirstOrDefault(); int idf = ph.phid; var phm = blog.Phabum.Where(a => a.phid == idf).FirstOrDefault(); string path = "~/images/" + phm.phtitle + "/" + ph.photos; string paths = Server.MapPath(path); bool sta = System.IO.File.Exists(paths); if (sta) { System.IO.File.Delete(paths); } else { return(Json(new { data = "删除失败", type = 0 }, JsonRequestBehavior.AllowGet)); } blog.Photograph.Remove(ph); blog.SaveChanges(); return(Json(new { data = "已删除", type = 1 }, JsonRequestBehavior.AllowGet)); } } } catch (Exception e) { return(Json(new { data = "删除失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }
// GET: Bloging /// <summary> /// 首页 /// </summary> /// <returns></returns> public ActionResult Index() { using (BlognEntities blo = new BlognEntities()) { List <Phabum> ji = blo.Phabum.ToList(); ViewData["photo"] = ji; var text = blo.Essay.ToList(); ViewData["text"] = text; //相册加图片 List <photoimg> photoimgs = new List <photoimg>(); foreach (var item in ji) { photoimg p = new photoimg(); int id = item.phid; List <Photograph> imgs = blo.Photograph.Where(a => a.phid == id).ToList(); p.phabums = item; p.pimg = imgs; photoimgs.Add(p); } ViewData["photoimgd"] = photoimgs; } return(View()); }
//相册详情 public ActionResult photoimg(string id) { if (id == "" || id == null) { return(Redirect("/Blogback/photo")); } int idd = int.Parse(id); using (BlognEntities blog = new BlognEntities()) { var ji = blog.Phabum.Where(a => a.phid == idd).FirstOrDefault(); if (ji == null) { return(Redirect("/Blogback/photo")); } else { var img = blog.Photograph.Where(a => a.phid == idd).ToList(); ViewData["ph"] = ji; ViewData["img"] = img; //评论 var ping = blog.Photocuss.Where(a => a.phid == idd).ToList(); var imgsc = new List <imgsc>(); foreach (var item in ping) { imgsc imgg = new Models.imgsc(); int usid = item.usid; imgg.ph = item; var j = blog.Usersd.Where(a => a.usid == usid).FirstOrDefault(); imgg.us = j; imgsc.Add(imgg); } ViewData["imgsc"] = imgsc; } } return(View()); }
//删除相册 public ActionResult phremoe(string id) { try { using (BlognEntities blog = new BlognEntities()) { int idd = int.Parse(id); var photo = blog.Phabum.Where(a => a.phid == idd).FirstOrDefault(); //删除图片 var photoimg = blog.Photograph.Where(a => a.phid == idd).ToList(); if (photoimg.Count() > 0) { foreach (var item in photoimg) {//删除图片 blog.Photograph.Remove(item); string path = "~/images/" + photo.phtitle + "/" + item.photos; string paths = Server.MapPath(path); bool sta = System.IO.File.Exists(paths); if (sta) { System.IO.File.Delete(paths); } } } //删除文件夹 string pathn = Server.MapPath("~/images/" + photo.phtitle); if (Directory.Exists(pathn)) //判断上传文件夹是否存在,若不存在,则创建 { Directory.Delete(pathn); //创建文件夹 } //删除相册点赞 var phlike = blog.Phlike.Where(a => a.phid == idd).ToList(); if (phlike.Count() > 0) { foreach (var item in phlike) { blog.Phlike.Remove(item); } } //删除评论点赞 var phc = blog.Photocuss.Where(a => a.phid == idd).ToList(); if (phc.Count() > 0) { foreach (var item in phc) { int i = item.pcid; var phcs = blog.Pclike.Where(a => a.plcid == i).ToList(); if (phcs.Count() > 0) { foreach (var items in phcs) { blog.Pclike.Remove(items); } } blog.Photocuss.Remove(item); } } blog.Phabum.Remove(photo); blog.SaveChanges(); return(Json(new { data = "已删除", type = 1 }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { data = "删除失败:" + e.Data, type = 0 }, JsonRequestBehavior.AllowGet)); } }