public ActionResult Category(int id, int? p, int? commend, int? f, string order) { var category = MyService.GetCategoryById(id); var currenturl = WebUtils.GetCateUrl(category); var webPath = MyService.GetCategoryPathUrl(category.Path); var pager = new Pager { PageNo = p ?? 1 }; switch (category.Type) { case 2: var re = MyService.GetVArticles(0, id, 0); if (re.Any()) { var varticle = re.ToList()[0]; var singleViewModel = new SingleViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, ArticleInfo = varticle, Category = category }; return View(WebUtils.GetViewName(category.CustomView, "Single"), singleViewModel); } return View("Error"); case 4: var albumsViewModel = new AlbumsViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, Category = category, Albums = MyService.GetAlbums(id), }; return View(WebUtils.GetViewName(category.CustomView, "Albums"), albumsViewModel); case 6: var note = new NoteModel { CategoryId = id, NoteId = 0, DataType = 1, UserId = UserInfo == null ? 0 : UserInfo.userid, UserName = UserInfo == null ? string.Empty : UserInfo.username }; pager.PageSize = Configinfo.NotePagerCount; var orderType = string.IsNullOrEmpty(order) ? "desc" : order; if (f != null && f > 0) { pager = MyService.GetFloorNoteByOrderId(pager, id, (long)f, orderType); } else { pager = MyService.GetFloorNotePaging(pager, id, orderType); } var noteViewModel = new NoteViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, Note = note, NoteList = new NoteListViewModel { NotePagerInfo = pager }, NoteOrderType = orderType, Category = category }; return View(WebUtils.GetViewName(category.CustomView, "Note"), noteViewModel); default: var iscommend = commend ?? 0; pager.PageSize = Configinfo.CatePagerCount; pager = category.SubCount > 0 ? MyService.GetArticlePaging(pager, 0, id, MyService.GetCategoryIds(id), iscommend, order) : MyService.GetArticlePaging(pager, 0, id, iscommend, order: order, articleListType: "category"); var categoryViewModel = new CategoryViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, IsCommend = iscommend, CateId = id, ArticlePagerInfo = pager, Category = category }; var articleListParasInfo = new AjaxArticleListParamsModel { ArticleListType = "category", CategoryId = id, Commend = iscommend, Order = order }; ViewBag.ArticleListParasInfo = articleListParasInfo; return View(WebUtils.GetViewName(category.CustomView, "Category"), categoryViewModel); } }
public ActionResult GetOneNote(long id) { var article = MyService.GetArticleById(id); var note = new NoteModel { CategoryId = article.cateid, NoteId = id, UserId = article.userid, UserName = article.username.Trim(), Email = article.title.Trim(), Url = article.summary.Trim(), Content = article.content }; return Json(note, "text/html;charset=UTF-8"); }
public ActionResult AjaxNote(NoteModel model) { if (Configinfo.UserPermission && UserInfo == null) { return JsonReturn("error.userpermission", string.Empty, string.Empty); } if (ModelState.IsValid) { if (Configinfo.IfValidateCode && model.ValidationCode != HttpContext.Session["validationCode"].ToString()) { return JsonReturn("error.validationcode", string.Empty, string.Empty); } if (UserInfo != null && (model.NoteId > 0 && UserInfo.userid == model.UserId)) { var article = MyService.GetArticleById(model.NoteId); article.title = model.Email.ExReturnNotNull().ExRemoveHtml(); article.summary = model.Url.ExReturnNotNull().ExRemoveHtml(); article.content = WebUtils.FileterData(model.Content, model.DataType); MyService.UpdateArticle(article); return JsonReturn(string.Empty, string.Empty, article.orderid.ToString()); } if (model.NoteId == 0) { var obj = InitialArticleModel.VArticle(); obj.title = model.Email.ExReturnNotNull().ExRemoveHtml(); obj.summary = model.Url.ExReturnNotNull().ExRemoveHtml(); obj.content = WebUtils.FileterData(model.Content, model.DataType); obj.layer = 0; obj.parentid = model.ParentId; obj.userid = model.UserId; obj.username = model.UserName.Trim(); obj.cateid = model.CategoryId; obj.typeid = 6; var re = MyService.AddArticle(obj); var newNote = MyService.GetArticleById(re); SendNoteReplyEmail(newNote); return JsonReturn(string.Empty, string.Empty, newNote.orderid.ToString()); } } return JsonReturn("error.modelvalid", string.Empty, string.Empty); }