protected void imbBtnCheckout_Click(object sender, ImageClickEventArgs e) { WishListTableAdapters.WishListDSTableAdapter wlTA = new WishListTableAdapters.WishListDSTableAdapter(); IEnumerator<WishList.WishListDSRow> wishLists = wlTA.GetWishListForUser(LoggedInUser.UserId).GetEnumerator(); while (wishLists.MoveNext()) { ShoppingTrolley.Web.Objects.Product product = ShoppingTrolley.Web.Objects.Product.LoadCompleteProduct(wishLists.Current.product_id); if (!wishLists.Current.Isproduct_detail_idNull()) { ShoppingCart.AddProductDetail(product, wishLists.Current.product_detail_id, wishLists.Current.version_id,wishLists.Current.quantity); } else ShoppingCart.AddProductVersion(product, wishLists.Current.version_id, wishLists.Current.quantity); } if (GetWishList().Count == 0) { SetErrorMessage("Please select alteast one item before checking out"); } else { if (LoggedInUser == null) { RedirectToLogin(); } else { Response.Redirect("~/pages/AccountAddress.aspx"); } } }
List<ShoppingItem> GetWishList() { List<ShoppingItem> shoppingItems = new List<ShoppingItem>(); if (LoggedInUser != null) { WishListTableAdapters.WishListDSTableAdapter ta = new WishListTableAdapters.WishListDSTableAdapter(); IEnumerator<WishList.WishListDSRow> wishLists = ta.GetWishListForUser(LoggedInUser.UserId).GetEnumerator(); while (wishLists.MoveNext()) { shoppingItems.Add(ShoppingItem.Load(wishLists.Current)); } } return shoppingItems; }