public IActionResult TagList() { var tags = _tagManager.GetAllEntities().ToList(); if (tags == null) { return(Json(new { code = 0, count = 0, msg = "失败", data = new { } })); } List <TagViewModel> taglist = new List <TagViewModel>(); for (int i = 0; i < tags.Count; i++) { taglist.Add(new TagViewModel { Id = tags[i].Id, IsInChina = tags[i].IsInChina, IsOpen = tags[i].IsOpen, Name = tags[i].Name, ShowId = i, Src = tags[i].Src, }); } var JsonResult = new { code = 0, count = tags.Count, msg = "成功", data = taglist }; return(Json(JsonResult)); }
public async Task <IActionResult> UpdateSiteInfo() { SiteInfo info = _siteInfoManager.GetAllEntities().FirstOrDefault(); if (info == null) { info = new SiteInfo(); } info.ArticleCount = _articleManager.GetAllEntities().Count(); info.TagCount = _tagManager.GetAllEntities().Count(); info.CommentCount = _commentManager.GetAllEntities().Count(); info.ColumnCount = (await _categoryManager.GetAllEntities().ToListAsync()).Count;//死数据,后期改 info.Views++; var result = _siteInfoManager.EditEntity(info); if (result) { return(Ok(new { code = 0, count = 1, msg = "成功", data = info })); } return(Ok(new { code = 1, count = 0, msg = "失败", data = string.Empty })); }