public ActionResult ViewImage(int id)
        {
            var IVM = new ImageViewModel();

            if (TempData["message"] != null)
            {
                IVM.Message = (string)TempData["message"];
            }
            if (!HasPermission(id))
            {
                IVM.HasPermission = false;
                IVM.Image         = new Image {
                    Id = id
                };
            }
            else
            {
                IVM.HasPermission = true;
                var Db = new ImageUploadDB(Properties.Settings.Default.ConStr);
                Db.UpdateViewCount(id);
                var image = Db.GetImagebyId(id);
                if (image == null)
                {
                    return(RedirectToAction("Index"));
                }
                IVM.Image = image;
            }

            return(View(IVM));
        }
        public ActionResult ViewImage(int id, string password)
        {
            var Db             = new ImageUploadDB(Properties.Settings.Default.ConStr);
            var uploadedImages = Db.GetImagebyId(id);

            if (uploadedImages == null)
            {
                return(RedirectToAction("Index"));
            }

            if (password != uploadedImages.Password)
            {
                TempData["message"] = "Invalid password";
            }
            else
            {
                List <int> allowedIds;
                if (Session["allowedids"] == null)
                {
                    allowedIds            = new List <int>();
                    Session["allowedids"] = allowedIds;
                }
                else
                {
                    allowedIds = (List <int>)Session["allowedids"];
                }

                allowedIds.Add(id);
            }

            return(Redirect($"/home/ViewImage?id={id}"));
        }