public ContentListResponse List(int?page, int?items) { try { var countTask = _contentService.CountAsync(); var dbContents = _contentService.GetAll(page, items); var contents = new List <Content>(); foreach (var dbContent in dbContents) { contents.Add(dbContent.MapToContent()); } countTask.Wait(); return(new ContentListResponse { Contents = contents, TotalContents = countTask.Result }); } catch (Exception ex) { return(new ContentListResponse { Success = false, Message = ex.Message }); } }
public ActionResult mIndex(string tag) { IEnumerable <VideoContent> videoContent = _contentService.GetAll(); if (!string.IsNullOrEmpty(tag)) { videoContent = videoContent.Where(x => x.Tag.ToLower().Contains(tag.ToLower())).ToList(); } return(View(videoContent)); }
// GET: Admin/Channel public ActionResult Index(string tag, DateTime?startDate) { IEnumerable <ChannelProgram> channelPrograms = _channelProgramService.GetAll().OrderBy(x => x.StartTime); IEnumerable <VideoContent> videoContents = _contentService.GetAll(); if (!string.IsNullOrEmpty(tag)) { videoContents = videoContents.Where(x => x.Tag.ToLower().Contains(tag.ToLower())); } if (startDate != null) { channelPrograms = channelPrograms.Where(x => x.StartTime.Date == startDate.Value.Date); } ChannelPageViewModel channelPageViewModel = new ChannelPageViewModel { ChannelPrograms = channelPrograms, VideoContents = videoContents }; return(View(channelPageViewModel)); }
/// <summary> /// 所有教学内容 /// </summary> /// <returns></returns> public static IEnumerable <SelectListItem> getAllContents() { var grades = new List <SelectListItem> (); var service = new ContentService(); var g = service.GetAll().GetEnumerator(); while (g.MoveNext()) { var sli = new SelectListItem(); sli.Text = g.Current.Name; sli.Value = g.Current.MyId.ToString(); //if (select != null && select.Id == g.Current.Id) // sli.Selected = true; grades.Add(sli); } return(grades); }
public PartialViewResult Contents() { var service = new ContentService(); return(PartialView("_Contents", service.GetAll())); }