Beispiel #1
0
        public IActionResult AddLike(int imgId)
        {
            var repo = new ImageRepository(_conStr);

            repo.AddLike(imgId);

            List <int> likedIds = HttpContext.Session.Get <List <int> >("likedids") ?? new List <int>();

            likedIds.Add(imgId);
            HttpContext.Session.Set("likedids", likedIds);

            return(Json(""));
        }
        public void Like(int id)
        {
            var repo = new ImageRepository(Properties.Settings.Default.ConStr);

            repo.AddLike(id);
            List <int> allowedIds;

            if (Session["allowedids"] == null)
            {
                allowedIds            = new List <int>();
                Session["allowedids"] = allowedIds;
            }
            else
            {
                allowedIds = (List <int>)Session["allowedids"];
            }

            allowedIds.Add(id);
        }
Beispiel #3
0
        public IActionResult AddLike(int id)
        {
            var connectionString = _configuration.GetConnectionString("ConStr");
            var repo             = new ImageRepository(connectionString);

            repo.AddLike(id);

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

            if (likedImages == null)
            {
                likedImages = new List <int>();
            }

            likedImages.Add(id);
            HttpContext.Session.Set("likedImages", likedImages);

            return(Json(repo.GetLikes(id)));
        }