public ActionResult All() { var tags = PostService.GetQuery(p => !string.IsNullOrEmpty(p.Label)).Select(p => p.Label).ToList().SelectMany(s => s.Split(',', ',')).GroupBy(t => t).Where(g => g.Count() > 1).OrderByDescending(g => g.Count()).ThenBy(g => g.Key).ToList(); //tag ViewBag.tags = tags; ViewBag.cats = CategoryService.GetAll(c => c.Post.Count, false).Select(c => new TagCloudViewModel { Id = c.Id, Name = c.Name, Count = c.Post.Count(p => p.Status == Status.Published || CurrentUser.IsAdmin) }).ToList(); //category ViewBag.seminars = SeminarService.GetAll(c => c.Post.Count, false).Select(c => new TagCloudViewModel { Id = c.Id, Name = c.Title, Count = c.Post.Count(p => p.Status == Status.Published || CurrentUser.IsAdmin) }).ToList(); //seminars return(View()); }
public ActionResult Save(Seminar seminar) { bool contain; if (seminar.Id > 0) { //更新 contain = SeminarService.GetAll().Select(s => s.Title).Except(new List <string>() { SeminarService.GetById(seminar.Id).Title }).Contains(seminar.Title); } else { //添加 contain = SeminarService.GetAll().Select(s => s.Title).Contains(seminar.Title); } if (contain) { return(ResultData(null, false, $"{seminar.Title} 已经存在了")); } var entry = SeminarService.GetById(seminar.Id); bool b; if (entry is null) { b = SeminarService.AddEntitySaved(seminar) != null; } else { entry.Description = seminar.Description; entry.Title = seminar.Title; entry.SubTitle = seminar.SubTitle; b = SeminarService.SaveChanges() > 0; } return(ResultData(null, b, b ? "保存成功" : "保存失败")); }
public ActionResult GetAll() { var list = SeminarService.GetAll <string, SeminarDto>(s => s.Title).ToList(); return(ResultData(list)); }