Пример #1
0
        public ActionResult addToWishList(int id, string urlCallBack)
        {
            //tim thu la th product nay da add vao wish list chua
            WishList w = _wishListService.GetAll().Where(m => m.ProductID == id && m.UserID == User.Identity.GetUserId()).FirstOrDefault();

            if (w != null)
            {
                _wishListService.deleteWishList(w.Id);
            }
            else
            {
                WishList newWishList = new WishList
                {
                    ProductID = id,
                    UserID    = User.Identity.GetUserId()
                };
                _wishListService.createWishList(newWishList);
            }

            if (urlCallBack != null)
            {
                return(RedirectToLocal(urlCallBack));
            }
            return(PartialView());
        }