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)); }
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 })); }
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)); }