public ActionResult Note(NoteModel model) { try { if (ModelState.IsValid) { CategoryModel category = myService.GetCategoryByID(model.CateId); if (configinfo.UserPermission == 1 && !Request.IsAuthenticated) return Redirect(WebUtils.GetCateUrl(category)); if (configinfo.IfValidateCode == 1) { if (model.ValidationCode != HttpContext.Session["validationCode"].ToString()) return Redirect(WebUtils.GetCateUrl(category)); } blog_varticle obj = InitialArticleModel.VArticle(); if (model.ReplyId > 0 && User.Identity.Name == model.UserName.Trim()) { obj = myService.GetVArticleByID(model.ReplyId); obj.title = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Email) ? "" : model.Email); obj.summary = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Url) ? "" : model.Url); obj.content = WebUtils.FileterData(model.Content, model.DataType); myService.UpdateArticle(obj); return Redirect(WebUtils.GetCateUrl(category) + "?f=" + obj.orderid.ToString()); } obj.typeid = Utils.StrToInt(category.Type); obj.cateid = model.CateId; obj.catepath = category.Path; obj.title = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Email) ? "" : model.Email); obj.summary = Utils.RemoveHtml(string.IsNullOrWhiteSpace(model.Url) ? "" : model.Url); obj.content = WebUtils.FileterData(model.Content, model.DataType); if (Request.IsAuthenticated) { obj.userid = 1; obj.username = User.Identity.Name; } else { obj.userid = 0; obj.username = model.UserName; } int re = myService.AddArticle(obj); string emailtitle = configinfo.Webtitle + " " + res.NoteReplyEmail; string authorinfo = obj.username; if (obj.userid == 1) { authorinfo = "<a href=\"" + configinfo.Weburl + "/u/" + HttpUtility.UrlEncode(obj.username, System.Text.Encoding.UTF8) + "\" target=\"_blank\">" + obj.username + "</a>"; } string emailcontent = model.Content + "<br><br>By " + authorinfo + "<br><hr>Url:" + configinfo.Weburl + WebUtils.GetCateUrl(category) + "?f=" + myService.GetArticleByID(re).orderid.ToString(); new sendDelegate(SendEmails).BeginInvoke(model.Content, emailtitle, emailcontent, re, 0, obj.userid, obj.username, null, null); return Redirect(WebUtils.GetCateUrl(category)); } return View("Error"); } catch { return View("Error"); } }
/// <summary> /// 留言本NoteBook /// </summary> public ActionResult NoteBook(int? p) { CategoryModel category = myService.GetCategoryByReName("NoteBook"); ViewBag.Title = category.CateName; ViewBag.WebPath = myService.GetCategoryPathUrl(category.Path); Pager pager = new Pager(); pager.PageNo = p ?? 1; NoteModel note = new NoteModel(); note.CateId = Utils.StrToInt(category.CateId); note.UserName = User.Identity.Name; pager.PageSize = configinfo.NotePagerCount; pager = myService.GetArticlePaging(pager, 0, note.CateId); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.CateId = note.CateId; ViewData["NoteList"] = pager.Entity; return View(WebUtils.GetViewName(category.CustomView, "Note"), note); }
public ActionResult Category(int id, int? p, int? commend, int? f) { try { CategoryModel category = myService.GetCategoryByID(id); ViewBag.Title = category.CateName; ViewBag.WebPath = myService.GetCategoryPathUrl(category.Path); string currenturl = WebUtils.GetCateUrl(category); ViewBag.CurrentUrl = currenturl; Pager pager = new Pager(); pager.PageNo = p ?? 1; switch(category.Type) { //单页 case "2": blog_varticle varticle = new blog_varticle(); var re = myService.GetArticles(0,id,0); if (re.Count() > 0) { varticle = re.ToList()[0]; varticle.viewcount++; myService.UpdateArticle(varticle); ViewBag.VoteTip = IsVote(varticle.id) ? res.Vote_Tip1 : res.Vote_Tip2; ViewBag.PreNextLink = GetNextPreArticleLink(varticle.id); ViewBag.ArticleId = varticle.id; return View(WebUtils.GetViewName(category.CustomView, "Article"), varticle); } else return View("Error"); //相册 case "4": return View(WebUtils.GetViewName(category.CustomView, "Albums"), myService.GetAlbums(id)); //留言板 case "6": if ((f ?? 0) > 0) { int floorpage = myService.GetArticlePageNo(configinfo.NotePagerCount, id, f ?? 0, 2); string paras = ""; paras += floorpage > 1 ? "&p=" + floorpage.ToString() : ""; paras = paras != "" ? "?" + paras.Trim('&') : ""; paras += "#f_" + f.ToString(); return Redirect(currenturl + paras); } NoteModel note = new NoteModel(); note.CateId = id; note.UserName = User.Identity.Name; pager.PageSize = configinfo.NotePagerCount; pager = myService.GetArticlePaging(pager, 0, id); ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.CateId = id; ViewData["NoteList"] = pager.Entity; return View(WebUtils.GetViewName(category.CustomView, "Note"), note); //文章列表 default: int iscommend = commend ?? 0; ViewBag.Commend = iscommend; pager.PageSize = configinfo.CatePagerCount; bool HasSub = true;//是否还有子分类 if (Utils.StrToInt(category.SubCount) > 0) { ViewData["CateLinks"] = myService.GetSonCategoryList(Utils.StrToInt(category.CateId)); pager = myService.GetArticlePaging(pager, 0, myService.GetCategoryIds(id), iscommend); } else { if (category.ParentId != "0") ViewData["CateLinks"] = myService.GetSonCategoryList(Utils.StrToInt(category.ParentId)); else ViewData["CateLinks"] = new List<CategoryModel>(); pager = myService.GetArticlePaging(pager, 0, id, iscommend); HasSub = false; } ViewBag.HasSub = HasSub; ViewBag.PageNo = p ?? 1; ViewBag.PageCount = pager.PageCount; ViewBag.CateId = id; string jsonSummaryImg = ""; pager.Entity = GetNewArticleQuery(pager.Entity as IQueryable<blog_varticle>, out jsonSummaryImg); ViewBag.SummaryImgs = jsonSummaryImg; return View(WebUtils.GetViewName(category.CustomView, "Category"),pager.Entity); } } catch { return View("Error"); } }