Exemplo n.º 1
0
        public static Dictionary <int, ShoppingCart> GetCheckoutGroupCart(SharedShoppingCart GroupShoppingCart, ShoppingCart bosscart) //int=bizId
        {
            Dictionary <int, ShoppingCart> groupcart = new Dictionary <int, ShoppingCart>();

            foreach (var k in GroupShoppingCart.PartyCart.Keys)
            {
                ShoppingCart sc = new ShoppingCart();
                sc = GroupShoppingCart.PartyCart[k];
                if (groupcart.ContainsKey(sc.BizId) == false)
                {
                    ShoppingCart cart = CopyShoppingCart(sc, bosscart);
                    groupcart.Add(sc.BizId, cart);
                }
                else
                {
                    groupcart[sc.BizId] = UnionShoppingCartItems(groupcart[sc.BizId], sc);
                }
            }
            foreach (var j in groupcart.Keys)
            {
                if (GroupShoppingCart.PartySubTotal() > 0)
                {
                    groupcart[j].DriverTip     = GroupShoppingCart.PartyDriverTip() * (groupcart[j].SubTotal() / GroupShoppingCart.PartySubTotal());
                    groupcart[j].TaxRate       = GroupShoppingCart.PartyTaxRate;
                    groupcart[j].serviceCharge = GroupShoppingCart.PartyServiceCharge / groupcart.Keys.Count;
                }
            }
            return(groupcart);
        }
Exemplo n.º 2
0
        public ActionResult GoCheckout(ShoppingCart cart)
        {
            HandleCart(cart);
            BizInfo      bi  = BizInfoRepository.GetBizInfoById(cart.BizId);
            AddItemModel aim = new AddItemModel();

            SharedShoppingCart ssc = new SharedShoppingCart();

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

            ViewBag.okcheckout = "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))
            {
                ViewBag.okcheckout = "off";
            }
            ssc.IsSharedCartLocked = true;
            aim.SharedCart         = ssc;
            aim.Cart = cart;
            return(PartialView(aim));
        }
Exemplo n.º 3
0
        public bool CanAddGroupItemToCart(string cartkey, decimal amount)
        {
            SharedShoppingCart sc = GetGroupShoppingCart(cartkey);

            if (sc == null)
            {
                return(false);
            }
            bool b = (sc.IsSharedCartLocked || (sc.PartySubTotal() + amount) > sc.MaxOrder);

            return(!b);
        }
Exemplo n.º 4
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
            }));
        }
Exemplo n.º 5
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")) }));
        }
Exemplo n.º 6
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
            }));
        }