예제 #1
0
 public bool InsertWishlistItem(WishlistItem wish)
 {
     myHandler = new BusinessLogicHandler();
     if (myHandler.AddWishlistItem(wish))
     {
         return true;
     }
     else
         return false;
 }
예제 #2
0
        public async Task<ActionResult> Add(int productId, string returnUrl)
        {
            WishlistActions act = new WishlistActions();
            if (User.Identity.IsAuthenticated)
            {
                ApplicationDbContext mycontext = new ApplicationDbContext();
                UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(mycontext);
                ApplicationUserManager mgr = new ApplicationUserManager(myStore);
                var thisUser = await mgr.FindByNameAsync(User.Identity.Name);

                WishlistItem wish = new WishlistItem();
                CartActions cart = new CartActions();
                wish.ProductID = productId;

                myHandler = new BusinessLogicHandler();
                IEnumerable<CartItem> inItems = myHandler.GetCartItems(thisUser.Carts.CartID);
                if (inItems != null)
                {
                    CartItem items = inItems.SingleOrDefault(item => item.ProductID == productId);
                    if (items != null)
                    {
                        if (items.ProductID == productId)
                        { myHandler = new BusinessLogicHandler(); myHandler.DeleteCartItem(items.CartItemID); }
                    }

                }
                wish.WishlistID = (int)thisUser.Wishlists.WishlistID;
                wish.DateAdded = DateTime.Now;
                myHandler.AddWishlistItem(wish);

                Session["wishlistTotal"] =  act.GetWishlistTotal(thisUser.Wishlists.WishlistID);
                Session["cartTotal"] =(double) cart.GetTotalAsync(thisUser.Carts.CartID);

                return Redirect(returnUrl);
            }
            else
            { return RedirectToAction("Account", "Login", null); }
        }
예제 #3
0
 public async Task<ActionResult> AddToCart(int ProductID, string returnUrl)
 {
     string userName = User.Identity.GetUserName();
     ApplicationDbContext dataSocket = new ApplicationDbContext();
     UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
     userMgr = new ApplicationUserManager(myStore);
     var user = await userMgr.FindByEmailAsync(userName);
     CartActions myActions = new CartActions();
     Cart cart = new Cart();
     cart.CartID = user.Carts.CartID;
     myHandler = new BusinessLogicHandler();
     IEnumerable<WishlistItem> inWishes = myHandler.GetWishlistItems(user.Wishlists.WishlistID);
     if (inWishes != null)
     {
         WishlistItem item = new WishlistItem();
         try
         {
             item = inWishes.SingleOrDefault(items => items.ProductID == ProductID);
             myHandler.DeleteWishlistItem(item.WishlistItemID);
             TempData["cartAdd"] = "1 item added to cart";
         }
         catch { }
     }
     if (myActions.AddToCartAsync(user.Carts.CartID, ProductID))
     {
         try
         {
             double nm = await GetCartTotal(user.Carts.CartID); string[] xn = nm.ToString().Split('.'); Session["cartTotal"] = xn[0] + "," + xn[1];
             
         }
         catch
         { Session["cartTotal"] = GetCartTotal(user.Carts.CartID); }
     }
     else
     { }
     return Redirect(returnUrl);
 }
예제 #4
0
        private void NextWishlistItem()
        {
            if (wishlist.Count >= 1)
            {
                currentWishItem = wishlist.Dequeue();

                allVideosIndex = currentWishItem.StartIndex;

                StartPage(currentWishItem.Url);
            }
            else
            {
                timer1.Stop();
            }
        }
예제 #5
0
        protected bool AllowPurchase(object dataItem)
        {
            WishlistItem item = (WishlistItem)dataItem;

            return(!item.Product.DisablePurchase);
        }