public JsonResult delcommentson(wenzhangpinglunson wps) { try { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL wz = new WenZhangBLL(); uif = DataToEnity <userinfo> .DataRowToEntity(wz.Getuserinfo(uif).Rows[0]); CommentBLL cb = new CommentBLL(); if (cb.iswenzhangzuoze(uif.id, wps.id)) { wps.pinglunrenid = uif.id; return(Json(new { issuf = cb.delcommentson(wps) })); } else if (cb.isgaipinglunsonzuoze(uif.id, wps.id)) { wps.pinglunrenid = uif.id; return(Json(new { issuf = cb.delcommentson(wps) })); } return(Json(new { issuf = false })); } catch { return(Json(new { issuf = true })); } }
/// <summary> /// 获取文章列表 /// </summary> /// <returns></returns> public IActionResult wenzhanglist() { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); List <userwenzhangkuozhan> wenzhangleixinglist = new List <userwenzhangkuozhan>(); if (data.Rows.Count == 1) { string leixing = GetKeyValue("leixing"); string keyword = GetKeyValue("keyword"); string qpagestart = GetKeyValue("page"); ViewData["nowpage"] = 1; string qpagecount = GetKeyValue("pagecount"); int pagestart = 0; int pagecount = 20; if (!string.IsNullOrEmpty(qpagestart) && !string.IsNullOrEmpty(qpagecount)) { pagestart = Convert.ToInt32(qpagestart); pagecount = Convert.ToInt32(qpagecount); ViewData["nowpage"] = pagestart + 1; } if (string.IsNullOrEmpty(leixing) || leixing == "-1") { ViewData["leixing"] = "-1"; wenzhangleixinglist = uib.Getuserwenzhanglist(data.Rows[0]["id"].ToString(), leixing = "-1", keyword, pagestart, pagecount); } else { ViewData["leixing"] = leixing; wenzhangleixinglist = uib.Getuserwenzhanglist(data.Rows[0]["id"].ToString(), leixing, keyword, pagestart, pagecount); } ViewData["dat"] = wenzhangleixinglist; return(View()); } else { wenzhangleixinglist.Add(new userwenzhangkuozhan() { count = 0, toal = 0 }); ViewData["dat"] = wenzhangleixinglist; return(View()); } }
/// <summary> /// 创建评论条 /// </summary> /// <param name="wzp"></param> /// <returns></returns> public JsonResult Addcomment(wenzhangpinglun wzp) { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; if (wzp.wenzhangid == 0 || wzp.pinglunneirong == null) { return(Json(new { msg = "操作出错" })); } if (string.IsNullOrEmpty(uif.username)) { userinfo userinfo = new userinfo() { id = 0, nicheng = "欠名", username = "******", touxiangurl = @"\images\header-img-comment_03.png" }; wenzhangpinglun wenzhangpinglun = new CommentBLL().addWenZhangPingLun(wzp); return(Json(new { issuf = true, wenzhangpinglun, userinfo })); } else { WenZhangBLL uib = new WenZhangBLL(); var uifdata = uib.Getuserinfo(uif); wzp.pinglunrenid = uifdata.Rows.Count != 0 ? Convert.ToInt32(uifdata.Rows[0]["id"]) : 0; if (wzp.pinglunrenid == 0) { return(Json(new { msg = "非法登陆,评论失败" })); } else { var userinfo = DataToEnity <userinfo> .DataRowToEntity(uifdata.Rows[0]); if (userinfo.touxiangurl == null) { userinfo.touxiangurl = @"\images\header-img-comment_03.png"; } if (userinfo.nicheng == null || userinfo.nicheng == "") { userinfo.nicheng = "未设置昵称"; } wenzhangpinglun wenzhangpinglun = new CommentBLL().addWenZhangPingLun(wzp); return(Json(new { issuf = true, wenzhangpinglun, userinfo })); } } }
/// <summary> /// 添加文章类型 /// </summary> /// <param name="uwz"></param> /// <returns></returns> public JsonResult addleixing(userwenzhangleixing uwz) { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); string leixingming = uwz.leixingming; if (string.IsNullOrEmpty(leixingming) && data.Rows.Count != 1) { return(Json(new { issuf = false })); } else { return(Json(new { issuf = uib.addleixing(data.Rows[0]["id"].ToString(), leixingming) })); } }
/// <summary> /// 文章详细页面 /// </summary> /// <returns></returns> public JsonResult getwenzhangdtl() { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); string wenzhangid = GetKeyValue("id"); if (string.IsNullOrEmpty(wenzhangid) && data.Rows.Count != 1) { return(Json(new { issuf = false })); } else { return(Json(new { issuf = true, dtl = uib.GetUserwenzhang(data.Rows[0]["id"].ToString(), wenzhangid) })); } }
public JsonResult editwenzhang(userwenzhang uwz) { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); uwz.userid = data.Rows.Count != 0 ? Convert.ToInt32(data.Rows[0]["id"]) : 0; if (string.IsNullOrEmpty(uwz.content) && string.IsNullOrEmpty(uwz.content100) && string.IsNullOrEmpty(uwz.wenzhangname) && uwz.id == 0) { return(Json(new { issuf = false, msg = "参数错误" })); } else { Result <userwenzhang> result = uib.editwenzhang(uwz, serverPath); return(Json(new { result })); } }
public JsonResult delwenzhang(userwenzhang uwz) { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); uwz.userid = data.Rows.Count != 0 ? Convert.ToInt32(data.Rows[0]["id"]) : 0; if (uwz.userid == 0 || uwz.id == 0) { return(Json(new { msg = "你是傻子吧" })); } else { Result <userwenzhang> result = uib.delwenzhang(uwz); return(Json(new { result })); } }
/// <summary> /// 获取文章类型 /// </summary> /// <returns></returns> public JsonResult wenzhangleixing() { userinfo uif = new userinfo(); uif.username = HttpContext.Request.Cookies["user"]; uif.pwd = HttpContext.Request.Cookies["key"]; WenZhangBLL uib = new WenZhangBLL(); var data = uib.Getuserinfo(uif); if (data.Rows.Count == 1) { var wenzhangleixinglist = uib.Getuserwenzhang(data.Rows[0]["id"].ToString()); var count = wenzhangleixinglist.Count; return(Json(new { issuf = true, wenzhangleixing = wenzhangleixinglist, count = count })); } else { return(Json(new { issuf = false, backurl = "/user/login" })); } }