// // GET: /Wellcome/ public ActionResult Index(string tab, int page=1) { DB.DAL.User a = auth.Autorizacija.GetCurrentUser(this.HttpContext); if (a != null) TempData["user"] = a; using (DBBL Baza = new DBBL()) { TempData["br_User"] = Baza.GetBrojUsera(); TempData["br_Wiki"] = Baza.GetBrojWiki(); TempData["br_QA"] = Baza.GetBrojQA(); var listaTopPitanja = Baza.context.Questions.OrderByDescending(q => q.NumOfViews).Take(7).ToList(); var listaTopWiki = Baza.context.Articles.OrderByDescending(q => q.Views).Take(7).ToList(); HttpContext.Cache.Insert("TopListaWiki", listaTopWiki); HttpContext.Cache.Insert("TopListaPitanja", listaTopPitanja); ViewBag.Kategorija = Baza.GetKatogorije(); ViewBag.AllCategory = Baza.context.Categories.ToList(); ViewBag.brojKomentara = Baza.context.Questions.Count(); var tagovi = Baza.context.Tags.Include(q=>q.Questions).OrderByDescending(q => q.Questions.Count).Take(50).ToList(); var randomLista = tagovi.OrderBy(q => q.TagID).ToList(); HttpContext.Cache.Insert("TopListaTagova", randomLista); if (tab == "popularno") { var questions = Baza.context.Questions.Include(q => q.Categories).Include(q => q.User).Include(q => q.QuestionLikes).Include(q => q.Tags).Include(q => q.Answers).OrderByDescending(q => q.Likes); if (Request.IsAjaxRequest()) { return PartialView("_render_questions", questions.ToList().ToPagedList(page, 5)); } return View(questions.ToList().ToPagedList(page, 2)); } if (tab == "najcitanije") { var questions = Baza.context.Questions.Include(q => q.Categories).Include(q => q.User).Include(q => q.Tags).Include(q=>q.QuestionLikes).Include(q => q.Answers).OrderByDescending(q => q.NumOfViews); if (Request.IsAjaxRequest()) { return PartialView("_render_questions", questions.ToList().ToPagedList(page, 5)); } return View(questions.ToList().ToPagedList(page, 5)); } else { var questions = Baza.context.Questions.Include(q => q.Categories).Include(q => q.User).Include(q => q.Tags).Include(q => q.Answers).Include(q=>q.QuestionLikes).OrderByDescending(q => q.CreatedDate); if (Request.IsAjaxRequest()) { return PartialView("_render_questions", questions.ToList().ToPagedList(page, 5)); } return View(questions.ToList().ToPagedList(page, 5)); } } }