Example #1
0
        public void OnPost(int productid)
        {
            test   = "Post";
            testid = productid;
            if (User.Identity.IsAuthenticated)
            {
                string id = _userManager.GetUserId(User);

                var query = from wishlist1 in _context.User_wishlist
                            where wishlist1.User_ID == id && wishlist1.Product_ID == productid
                            select wishlist1;

                User_Wishlist wishlist_check = query.FirstOrDefault();
                if (wishlist_check == null)
                {
                    Console.WriteLine("");
                    User_Wishlist wishlist = new User_Wishlist()
                    {
                        User_ID    = id.ToString(),
                        Product_ID = productid
                    };
                    _context.User_wishlist.Add(wishlist);
                    _context.SaveChanges();
                }
            }


            Response.Redirect("../Productinfo?id=" + productid + "&ProductAdded=FavoriteAdd");
        }
Example #2
0
        // delete vanuit productinfo
        public async Task <IActionResult> OnPostDeleteAsync(string id, int wish)
        {
            if (id == null)
            {
                return(NotFound());
            }

            User_Wishlist = await _context.User_wishlist.FindAsync(id, wish);

            if (User_Wishlist != null)
            {
                _context.User_wishlist.Remove(User_Wishlist);
                await _context.SaveChangesAsync();
            }

            return(Redirect("../Productinfo?id=" + wish + "&ProductAdded=FavoriteDelete"));
        }
Example #3
0
        // delete vanuit wishlist
        public async Task <IActionResult> OnPostAsync(string id, int wish)
        {
            if (id == null)
            {
                return(NotFound());
            }

            User_Wishlist = await _context.User_wishlist.FindAsync(id, wish);

            if (User_Wishlist != null)
            {
                _context.User_wishlist.Remove(User_Wishlist);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("/Wishlist/Wishlist"));
        }
Example #4
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            User_Wishlist = await _context.User_wishlist
                            .Include(u => u.Product)
                            .Include(u => u.User).SingleOrDefaultAsync(m => m.User_ID == id);

            if (User_Wishlist == null)
            {
                return(NotFound());
            }
            return(Page());
        }