コード例 #1
0
        public IActionResult ViewPic(int id)
        {
            var             db    = new ImageDb(_connectionString);
            UploadViewModel vm    = new UploadViewModel();
            Image           image = db.GetImages().FirstOrDefault(i => i.Id == id);

            vm.Image = image;
            vm.Image.Views++;
            db.UpdateViewCount(vm.Image);

            List <int> ids = HttpContext.Session.Get <List <int> >("ApprovedIds");

            if (ids == null)
            {
                ids = new List <int>();
            }
            if (!ids.Contains(image.Id))
            {
                ids.Add(image.Id);
            }
            HttpContext.Session.Set("ApprovedIds", ids);

            return(View(vm));
        }