Ejemplo n.º 1
0
        public JsonResult CheckExist(string productId)
        {
            var wishlistDTO = new WishlistDTO
            {
                UserId    = User.Identity.GetUserId(),
                ProductId = productId
            };

            if (!_wishlistRepo.CheckExist(wishlistDTO))
            {
                return(Json(new
                {
                    exist = false
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                exist = true
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult AddToWishlist(string productId)
        {
            var wishlistDTO = new WishlistDTO
            {
                UserId    = User.Identity.GetUserId(),
                ProductId = productId
            };

            var result = _wishlistRepo.AddToWishlist(wishlistDTO);

            if (!result)
            {
                return(Json(new
                {
                    success = false
                }));
            }

            return(Json(new
            {
                success = true
            }));
        }
Ejemplo n.º 3
0
 public bool CheckExist(WishlistDTO wishlistDTO)
 {
     return(_context.Wishlists.FirstOrDefault(w => w.UserId == wishlistDTO.UserId && w.ProductId == wishlistDTO.ProductId) != null);
 }
 // [Route("{id:int}")]
 public IHttpActionResult Post(WishlistDTO wishlist)
 {
     wishlistService.AddOrUpdateWishlist(wishlist);
     return(Ok(wishlist));
 }