public ActionResult AdminAdd(ArticleModel model) { if (ModelState.IsValid) { var cateid = model.CateId; if (cateid == 0) { var newcate = new CategoryModel { CateName = "syscreate", IsIndex = true, IsNav = false, ListNum = 0, ParentId = 0, ReName = string.Empty, CustomView = string.Empty, ReplyPermit = 2, Status = 1, Type = model.TypeId, Description = string.Empty, SubCount = 0 }; cateid = AddNewCategory(newcate); } blog_varticle obj = InitialArticleModel.VArticle(); CategoryModel category = MyService.GetCategoryById(cateid); obj.typeid = category.Type; obj.cateid = model.CateId; obj.catepath = category.Path; obj.title = Utils.FileterStr(model.Title); obj.summary = string.IsNullOrWhiteSpace(model.Summary) ? "" : model.Summary; obj.content = Utils.DownloadImages(model.Content, "~/upload/article/", GetRootPath()); obj.tags = (string.IsNullOrWhiteSpace(model.Tags) ? "" : model.Tags).Trim(); obj.replypermit = model.ReplyPermit; obj.seodescription = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoDescription) ? "" : model.SeoDescription)).Trim(); obj.seokeywords = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.Seokeywords) ? "" : model.Seokeywords)).Trim(); obj.seometas = string.IsNullOrWhiteSpace(model.SeoMetas) ? "" : model.SeoMetas; obj.seotitle = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoTitle) ? "" : model.SeoTitle)).Trim(); obj.rename = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.ReName) ? "" : model.ReName)).Trim(); obj.status = model.Status; obj.userid = MyService.GetUserInfo(UserInfo.username).UserId; obj.username = UserInfo.username; obj.iscommend = model.IsCommend; obj.istop = model.IsTop; obj.isindextop = model.IsIndexTop; var re = MyService.AddArticle(obj); var createHtml = Configinfo.IfHtmlCreated == 1 || Configinfo.IfWebStatic == 1; if (createHtml && category.Type == 1 && obj.status == 1) { new CreatePageDelegate(WebUtils.CreateHtml).BeginInvoke(obj.typeid, re, obj.rename, obj.createdate, GetRootPath(), null, null); } return(RedirectToAction("AdminArticle", new { tid = obj.typeid, cid = obj.cateid })); } return(View(model)); }
private ArticleViewModel ConvertToArticleViewModel(blog_varticle varticle) { return(new ArticleViewModel { WebTitle = WebUtils.MyString(varticle.seotitle, varticle.title), WebPath = MyService.GetCategoryPathUrl(varticle.catepath), Seo = WebUtils.GetSeoInfo(varticle), ArticleInfo = varticle, Category = MyService.GetCategoryById(varticle.cateid) }); }
public AlbumModel GetAlbum(blog_varticle varticle) { var album = new AlbumModel(); if (varticle != null) { album.Varticle = varticle; AlbumPhotoModel cover; album.ImageList = GetAlbumPhotoList(varticle.content, out cover); album.Cover = cover; album.ImgCount = album.ImageList.Count(); album.Category = GetCategoryById(varticle.cateid); } return(album); }
public long AddArticle(blog_varticle varticle) { string lang; var obj = varticle; if (obj.parentid > 0) { lang = obj.layer == 0 ? GetArticleById(obj.parentid).lang : GetArticleById(obj.articleid).lang; } else { lang = WebUtils.GetCurrentLangStr(); } obj.lang = lang; _entity.blog_varticle.AddObject(obj); _entity.SaveChanges(); return(obj.id); }
public blog_varticle GetNextVArticle(blog_varticle varticle, int tid, int cid = 0, string field = "") { var re = new blog_varticle(); var query = GetVArticles(tid, cid, 0); if (field != "") { switch (field) { case "lastpost": re = query.Where(m => m.lastreplydate > varticle.lastreplydate).OrderBy(m => m.lastreplydate).FirstOrDefault(); break; } } else { re = query.Where(m => m.id > varticle.id).OrderBy(m => m.id).FirstOrDefault(); } return(re); }
public static blog_varticle VArticle() { var varticle = new blog_varticle { articleid = 0, typeid = 0, cateid = 0, catepath = string.Empty, title = string.Empty, summary = string.Empty, content = string.Empty, tags = string.Empty, layer = 0, orderid = 1, parentid = 0, replypermit = 1, seodescription = string.Empty, seokeywords = string.Empty, seometas = string.Empty, seotitle = string.Empty, rename = string.Empty, status = 1, userid = 0, username = string.Empty, iscommend = 2, istop = 2, isindextop = 2, articletypeid = 0, viewcount = 0, createdate = DateTime.Now, lastreplydate = DateTime.Now, ip = Utils.GetIp() }; return(varticle); }
public static string GetArticleUrl(blog_varticle varticle) { return(!string.IsNullOrWhiteSpace(varticle.rename) ? "/article/" + varticle.rename : "/archive/" + varticle.id); }
public static string YqUrl(this HtmlHelper helper, blog_varticle varticle) { return(WebUtils.GetYqUrl(varticle)); }
public blog_varticle GetNextVArticle(blog_varticle varticle) { return(GetNextVArticle(varticle, varticle.typeid)); }
public blog_varticle GetPreviewVArticle(blog_varticle varticle) { return(GetPreviewVArticle(varticle, varticle.typeid)); }