示例#1
0
        public IActionResult GetFilteredGenres(int websiteId)
        {
            HttpContext.Session.SetInt32("websiteId", websiteId);

            GenreContext genreContext = HttpContext.RequestServices.GetService(typeof(GenreContext)) as GenreContext;

            ViewData["genres"] = genreContext.ListGenres(websiteId);

            return(PartialView("_Genres"));
        }
示例#2
0
        public IActionResult Index()
        {
            var            websiteid      = 3;
            ArticleContext articleContext = HttpContext.RequestServices.GetService(typeof(ArticleContext)) as ArticleContext;

            if (!articleContext.CheckConnection())
            {
                return(Content("Could not establish connection to the database."));
            }

            ViewData["articles"] = articleContext.GetAllArticles(websiteid).OrderByDescending(a => a.Date).ToList();

            GenreContext genreContext = HttpContext.RequestServices.GetService(typeof(GenreContext)) as GenreContext;

            ViewData["genres"] = genreContext.ListGenres(websiteid);

            return(View());
        }