Пример #1
0
        public JsonResult AddWishList(long goodId)
        {
            var resultCode = 0;
            var customer   = new CustomerAction(Session.GetUserId());

            try
            {
                customer.AddToWishList(goodId);
            }
            catch (Exception)
            {
                resultCode = -1;
            }
            try
            {
                Session.UpdateWishList();
                var wishList = Session.GetUser().wishList;
                var result   = new { result = resultCode, wishCount = (customer.GetWishList()?.Count() ?? 0) };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                resultCode = -2;
                var result = new { result = resultCode, wishCount = 0 };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        public ActionResult WishList()
        {
            var customer = new CustomerAction(Session.GetUserId());
            var wishlist = customer.GetWishList();

            return(View(wishlist));
        }
Пример #3
0
 public static void UpdateWishList(this HttpSessionStateBase sbase)
 {
     if (IsAuth(sbase))
     {
         var user     = GetUser(sbase);
         var customer = new CustomerAction(user.id);
         user.wishList = customer.GetWishList();
     }
 }
Пример #4
0
        public void TestWishList()
        {
            var customer = new CustomerAction(8);
            var store    = new StoreAction();

            customer.AddToWishList(3);
            customer.AddToWishList(4);
            customer.AddToWishList(5);

            var withList = customer.GetWishList();

            Assert.IsTrue(withList.Count() > 2);

            customer.DeleteWishList(3);
            Assert.IsNull(customer.GetWishList().FirstOrDefault(s => s.id == 3));

            customer.ClearWishList();
            Assert.IsTrue(customer.GetWishList().Count() == 0);
        }
Пример #5
0
        public static void Login(this HttpSessionStateBase sbase, long userId)
        {
            var account = new AccountAction();
            var user    = account.GetUserInfo(new UserIdModel {
                userId = userId
            });
            var customer = new CustomerAction(userId);

            user.basket   = customer.GetBasket();
            user.wishList = customer.GetWishList();
            SetUser(sbase, user);
        }