示例#1
0
 // Constrain
 public checkoutProcess(List<checkoutPageItem> stepLinkList, topCart cartItem)
 {
     this.stepLinkList = stepLinkList;
     this.cartItem = cartItem;
     this.transferInfo = new transferInfo();
     this.cardInfo = new cardInfo();
 }
示例#2
0
        private void bindBasketAndRegisterUrl(titizOtoEntities db, int langId, topCart helperItem)
        {
            pageShared ps = new pageShared(db);

            var registerPage = ps.getPageByType(pageType.registerLogin, langId);
            if (registerPage != null)
            {
                helperItem.registerUrl = registerPage.url + ".html";
            }

            var basketPage = ps.getPageByType(pageType.basket, langId);
            if (basketPage != null)
            {
                helperItem.basketUrl = basketPage.url + ".html";
            }
        }
示例#3
0
        public Tuple<bool, decimal, string> getProductPrice(topCart cartItem, int langId, string langCode, string mainPath, bool isDeletedInclude)
        {
            // get Basket Content => Price , Discount
            helperBasket helperBasket = new helperBasket();
            basketShared bs = new basketShared(db);
            var basketContent = bs.getBasketHelperWithProductAndDiscount(cartItem, langId, langCode, mainPath, isDeletedInclude);
            if (basketContent.Item2 == basketActionResult.redirect)
            {
                return new Tuple<bool, decimal, string>(false, 0, "basket");
            }

            helperBasket = basketContent.Item1;
            var basketTotal = helperBasket.totalPriceDec;

            return new Tuple<bool, decimal, string>(true, basketTotal, null);
        }
        public bool isCartSame(topCart obj1, topCart obj2)
        {
            bool isSame = true;

            if (obj1.basketUrl != obj2.basketUrl)
            {
                isSame = false;
            }

            if (obj1.guestGuid != obj2.guestGuid)
            {
                isSame = false;
            }

            if (obj1.isRegisteredUser != obj2.isRegisteredUser)
            {
                isSame = false;
            }

            if (obj1.nameSurname != obj2.nameSurname)
            {
                isSame = false;
            }

            if (obj1.productCount != obj2.productCount)
            {
                isSame = false;
            }

            if (obj1.registerUrl != obj2.registerUrl)
            {
                isSame = false;
            }

            if (obj1.userGuid != obj2.userGuid)
            {
                isSame = false;
            }

            if (obj1.userId != obj2.userId)
            {
                isSame = false;
            }

            if (obj1.basketIdString != obj2.basketIdString)
            {
                isSame = false;
            }

            return isSame;
        }
示例#5
0
        public Tuple<helperBasket, basketActionResult> getBasketHelperWithProductAndDiscount(topCart cartItem, int langId, string langCode, string mainPath, bool isDeletedInclude)
        {
            discountShared ds = new discountShared(db);
            helperBasket helperPage = new helperBasket();

            var basketContentItem = getBasketContent(cartItem, langId, langCode, mainPath, isDeletedInclude);

            helperPage.basketList = basketContentItem.Item1;
            helperPage.actionMsg = basketContentItem.Item2;

            if (!helperPage.isBasketValid)
            {
                return new Tuple<helperBasket, basketActionResult>(null, basketActionResult.redirect);
            }

            // Discount Calculate
            var discountObject = ds.getDiscountSummary(basketContentItem.Item1, cartItem.userId);
            if (discountObject.Item2)
            {
                helperPage.discountList = discountObject.Item1;
                helperPage.isDiscountValid = discountObject.Item2;
            }

            if (!helperPage.isDiscountValid)
            {
                return new Tuple<helperBasket, basketActionResult>(null, basketActionResult.redirect);
            }

            helperPage.calculateSum();

            return new Tuple<helperBasket, basketActionResult>(helperPage, basketActionResult.success);
        }
示例#6
0
        /// <summary>
        ///  List<basketItem> -- Basket Content  &  basketActionResult-- StockAdjust , Redirect ( Clear ) ...
        /// </summary>  
        public Tuple<List<basketItem>, basketActionResult> getBasketContent(topCart cartItem, int langId, string langCode, string mainPath, bool isDeletedInclude)
        {
            List<tbl_basket> list = new List<tbl_basket>();

            int userId = cartItem.userId;
            string guestCode = cartItem.guestGuid;

            if (cartItem.isRegisteredUser)
            {
                list = db.tbl_basket.Include("tbl_product.tbl_productCritear.tbl_critear").Include("tbl_product.tbl_gallery").Where(a => a.userId == userId).ToList();
            }
            else
            {
                list = db.tbl_basket.Include("tbl_product.tbl_productCritear.tbl_critear").Include("tbl_product.tbl_gallery").Where(a => a.guestCode == guestCode).ToList();
            }

            // Action && Basket Content
            return getBasketListByTblBasket(list, isDeletedInclude);
        }
示例#7
0
        private topCart getGuestCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId)
        {
            httpSessionStateBase["userId"] = null;

            topCart helperItem = new topCart();

            string guestGuid = "";
            if (httpSessionStateBase["guestGuid"] != null)
            {
                guestGuid = httpSessionStateBase["guestGuid"].ToString();
                if (guestGuid == "System.Web.HttpCookie" || guestGuid == "00000000-0000-0000-0000-000000000000")
                {
                    guestGuid = getGuidCookieOrNew(request, response);
                    httpSessionStateBase["guestGuid"] = guestGuid;
                }

            }
            else
            {
                guestGuid = getGuidCookieOrNew(request, response);
            }

            helperItem.guestGuid = guestGuid;

            var basketList = db.tbl_basket.Where(a => a.guestCode == guestGuid).ToList();
            if (basketList != null && basketList.Count > 0)
            {
                helperItem.basketIdString = string.Join(",", basketList.Select(a => a.basketId).ToList());
                helperItem.productCount = basketList.Sum(a => a.quantity);
            }

            return helperItem;
        }
示例#8
0
        private topCart getUserCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId)
        {
            int userId = 0;
            topCart helperItem = new topCart();

            if (int.TryParse(httpSessionStateBase["userId"].ToString(), out userId))
            {

                var userItem = db.tbl_user.Where(a => a.userId == userId).FirstOrDefault();

                if (userItem != null)
                {
                    helperItem.isRegisteredUser = true;
                    helperItem.userId = userId;
                    helperItem.nameSurname = userItem.name + " " + userItem.surname;
                    helperItem.guestGuid = null;
                    helperItem.userGuid = userItem.guid;

                    var cartList = db.tbl_basket.Where(a => a.userId == userId).ToList();

                    if (cartList != null && cartList.Count > 0)
                    {
                        helperItem.basketIdString = string.Join(",", cartList.Select(a => a.basketId).ToList());
                        helperItem.productCount = cartList.Sum(a => a.quantity);
                    }
                    else
                    {
                        helperItem.productCount = 0;
                    }

                    return helperItem;
                }

            }

            return null;
        }
示例#9
0
        private topCart getTopCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId)
        {
            topCart helperItem = new topCart();

            bool isGuest = true;

            if (httpSessionStateBase["userId"] != null)
            {
                helperItem = getUserCartItem(db, httpSessionStateBase, request, response, langId);

                if (helperItem != null)
                {
                    isGuest = false;
                }
            }

            if (isGuest)
            {
                helperItem = getGuestCartItem(db, httpSessionStateBase, request, response, langId);
            }

            bindBasketAndRegisterUrl(db, langId, helperItem);

            return helperItem;
        }