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)); } }
public ActionResult WishList() { var customer = new CustomerAction(Session.GetUserId()); var wishlist = customer.GetWishList(); return(View(wishlist)); }
public static void UpdateWishList(this HttpSessionStateBase sbase) { if (IsAuth(sbase)) { var user = GetUser(sbase); var customer = new CustomerAction(user.id); user.wishList = customer.GetWishList(); } }
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); }
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); }