// GET: Discussion public ActionResult Latest() { ViewBag.Title = "Najnowsze dyskusje"; List <Discussion> lista = repo.GetElementsNoTracking().OrderByDescending(x => x.Date).Take(10).ToList(); return(View("Discussions", lista)); }
public ActionResult MostPopular() { List <dynamic> list = new List <dynamic>(); IEnumerable <Article> art = repoa.GetElementsNoTracking().OrderBy(x => x.Date).Take(3); IEnumerable <Discussion> dis = repod.GetElementsNoTracking().OrderBy(x => x.Date).Take(3); IEnumerable <Satire> sat = repos.GetElementsNoTracking().OrderBy(x => x.Date).Take(3); int[] integers = new int[] { art.Count(), dis.Count(), sat.Count() }; int integer = (integers[0] > 3 && integers[1] > 3 && integers[2] > 3) ? 3 : integers.Min(); for (var i = 0; i < integer; i++) { var tymart = art.ElementAt(i); var tymdis = dis.ElementAt(i); var tymsat = sat.ElementAt(i); if (tymart.Date.Ticks > tymdis.Date.Ticks) { if (tymart.Date.Ticks > tymsat.Date.Ticks) { list.Add(tymart); } else { list.Add(tymsat); } } else { if (tymdis.Date.Ticks > tymsat.Date.Ticks) { list.Add(tymdis); } else { list.Add(tymsat); } } } return(PartialView(list)); }