Esempio n. 1
0
        public ActionResult RemovePerson(string id, ShoppingCart cart) // id=PersonName
        {
            HandleCart(cart);
            string             islocked = "yes";
            SharedShoppingCart ssc      = new SharedShoppingCart();

            if (string.IsNullOrEmpty(cart.CartKey) == false)
            {
                ssc = GetGroupShoppingCart(cart.CartKey);
            }
            if (ssc.IsSharedCartLocked == false)
            {
                islocked = "no";
                ShoppingCart sc = new ShoppingCart();
                sc = ssc.PartyCart[id];
                ssc.DeleteCart(id);
                // sc = null;
                sc.Clear();
            }
            string btnShow = "show";
            bool   isBoss  = (string.IsNullOrEmpty(cart.PersonName) == false && cart.PersonName == GroupCart.GroupCarts[cart.CartKey].PartyBossName);

            if (!isBoss || GroupCart.GroupCarts[cart.CartKey].PartyTotalItems == 0 || (GroupCart.GroupCarts[cart.CartKey].PartyOrderMinimum() > GroupCart.GroupCarts[cart.CartKey].PartySubTotal() && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery) || (GroupCart.GroupCarts[cart.CartKey].PartyCart[cart.BossName].IsBizDelivery == false && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery))
            {
                btnShow = "off";
            }
            decimal cartTax        = ssc.PartyTax();
            decimal globalsubTotal = ssc.PartySubTotal();
            decimal globalTotal    = ssc.PartyTotal();
            int     cartItems      = ssc.PartyTotalItems;

            return(Json(new
            {
                islocked = islocked,
                name = id,
                total = ToUSD(globalTotal.ToString("N2")),
                carttax = ToUSD(cartTax.ToString("N2")),
                drivertip = ToUSD(ssc.PartyDriverTip().ToString("N2")),
                globalsubtotal = ToUSD(globalsubTotal.ToString("N2")),
                btnshow = btnShow
            }));
        }
Esempio n. 2
0
        public ActionResult UpdateQuantity(ShoppingCart cart, string itemId, string qty = "0")
        {
            BizInfo          bi      = BizInfoRepository.GetBizInfoById(cart.BizId);
            ShoppingCartItem sci     = cart.GetCartLineByItemId(itemId);
            string           timeout = "timein";

            if (bi == null || sci == null)
            {
                timeout = "timeout";
                return(Json(new
                {
                    timeexp = timeout,
                    canupdatequantity = "n"
                }));
            }

            if (string.IsNullOrEmpty(cart.CartKey))
            {
                return(Json(new
                {
                    timeexp = timeout,
                    canupdatequantity = "n"
                }));
            }
            SharedShoppingCart ssc = new SharedShoppingCart();

            if (string.IsNullOrEmpty(cart.CartKey) == false)
            {
                ssc = GetGroupShoppingCart(cart.CartKey);
            }
            int  quty       = int.Parse(qty);
            int  beforeQuty = sci.Quantity;
            bool bl         = CanAddGroupItemToCart(cart.CartKey, (quty - beforeQuty) * sci.ItemPrice);

            if (bl)
            {
                cart.UpdateItemQuantity(itemId, quty);
            }
            decimal partysubtotal = ssc.PartySubTotal();

            string btnShow = "show";

            if (string.IsNullOrEmpty(itemId) == false)
            {
                bool isBoss = (string.IsNullOrEmpty(cart.PersonName) == false && cart.PersonName == GroupCart.GroupCarts[cart.CartKey].PartyBossName);
                if (GroupCart.GroupCarts[cart.CartKey].PartyTotalItems == 0 || (GroupCart.GroupCarts[cart.CartKey].PartyOrderMinimum() > GroupCart.GroupCarts[cart.CartKey].PartySubTotal() && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery) || (GroupCart.GroupCarts[cart.CartKey].PartyCart[cart.BossName].IsBizDelivery == false && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery))
                {
                    btnShow = "off";
                }

                decimal productSubTotal = sci.ItemTotal;
                decimal cartTax         = ssc.PartyTax();
                decimal subTotal        = cart.SubTotal();;
                decimal globalsubTotal  = partysubtotal;
                decimal globalTotal     = ssc.PartyTotal();
                int     cartItems       = ssc.PartyTotalItems;
                return(Json(new
                {
                    timeexp = timeout,
                    canupdatequantity = bl ? "y" : "n",
                    isboss = isBoss ? "yes" : "no",
                    delMin = ssc.PartyOrderMinimum().ToString("N2"),
                    isDelivery = ssc.IsPartyDelivery ? "delivery" : "pickup",
                    itemid = itemId,
                    qutty = quty.ToString(),
                    producttitle = sci.Title,
                    uniteprice = ToUSD(sci.FinalPrice.ToString("N2")),
                    total = ToUSD(globalTotal.ToString("N2")),
                    cartitems = cartItems.ToString(),
                    carttax = ToUSD(cartTax.ToString("N2")),
                    drivertip = ToUSD(ssc.PartyDriverTip().ToString("N2")),
                    subtotal = ToUSD(subTotal.ToString("N2")),
                    globalsubtotal = ToUSD(globalsubTotal.ToString("N2")),
                    productsubtotal = ToUSD(productSubTotal.ToString("N2")),
                    btnshow = btnShow
                }));
            }
            return(Json(new { total = ToUSD(ssc.PartyTotal().ToString("N2")) }));
        }
Esempio n. 3
0
        public ActionResult UpdateDelivery(string del, ShoppingCart cart, BrowseHistory bh)
        {
            string  timeout = "timein";
            BizInfo bi      = BizInfoRepository.GetBizInfoById(cart.BizId);

            if (bi == null)
            {
                timeout = "timeout";
                return(Json(new
                {
                    timeexp = timeout
                }));
            }
            SharedShoppingCart ssc = new SharedShoppingCart();

            if (string.IsNullOrEmpty(cart.CartKey) == false)
            {
                ssc = GetGroupShoppingCart(cart.CartKey);
            }

            /*
             * if (ssc.IsSharedCartLocked)
             * {
             *  return Json(new
             *  {
             *      timeexp = timeout,
             *      sharelocked = "yes"
             *  });
             * }
             */
            decimal partysubtotal = ssc.PartySubTotal();

            bh.IsDelivery       = del == "true" ? true : false;
            ssc.IsPartyDelivery = bh.IsDelivery;

            string btnShow = "show";
            bool   isBoss  = (string.IsNullOrEmpty(cart.PersonName) == false && cart.PersonName == GroupCart.GroupCarts[cart.CartKey].PartyBossName);

            if (GroupCart.GroupCarts[cart.CartKey].PartyTotalItems == 0 || (GroupCart.GroupCarts[cart.CartKey].PartyOrderMinimum() > GroupCart.GroupCarts[cart.CartKey].PartySubTotal() && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery) || (GroupCart.GroupCarts[cart.CartKey].PartyCart[cart.BossName].IsBizDelivery == false && GroupCart.GroupCarts[cart.CartKey].IsPartyDelivery))
            {
                btnShow = "off";
            }
            decimal cartTax        = ssc.PartyTax();
            decimal subTotal       = cart.SubTotal();;
            decimal globalsubTotal = partysubtotal;
            decimal cartTotal      = ssc.PartyTotal();

            return(Json(new
            {
                timeexp = timeout,
                sharelocked = ssc.IsSharedCartLocked ? "yes" : "no",
                isboss = isBoss ? "yes" : "no",
                isdelivery = ssc.IsPartyDelivery ? "delivery" : "pickup",
                delfee = ssc.PartyDeliveryFee().ToString("N2"),
                drivertip = ToUSD(ssc.PartyDriverTip().ToString("N2")),
                delMin = ssc.PartyOrderMinimum().ToString("N2"),
                globaltotal = ToUSD(cartTotal.ToString("N2")),
                // globalsubtotal = ToUSD(globalsubTotal.ToString("N2")),
                // carttax = ToUSD(cartTax.ToString("N2")),
                // subtotal = ToUSD(subTotal.ToString("N2")),
                btnshow = btnShow
            }));
        }