Пример #1
0
        public CheeseAmount AddCheeseAmount(int vCheeseAmountID, int vProductID, string vTitle, string vDescription, decimal vPrice, decimal vBizPrice, DateTime vAddedDate, string vAddedBy, DateTime vUpdatedDate, string vUpdatedBy, bool vActive)
        {
            CheeseAmount lCheeseAmount = new CheeseAmount();

            using (FRShoppingEntities frctx = new FRShoppingEntities())
            {
                if (vCheeseAmountID > 0)
                {
                    lCheeseAmount             = frctx.CheeseAmounts.FirstOrDefault(u => u.CheeseAmountId == vCheeseAmountID);
                    lCheeseAmount.Title       = vTitle;
                    lCheeseAmount.Description = vDescription;
                    lCheeseAmount.Price       = vPrice;
                    lCheeseAmount.BizPrice    = vBizPrice;
                    lCheeseAmount.UpdatedDate = vUpdatedDate;
                    lCheeseAmount.UpdatedBy   = vUpdatedBy;
                    lCheeseAmount.Active      = vActive;
                    return(frctx.SaveChanges() > 0 ? lCheeseAmount : null);
                }
                else
                {
                    lCheeseAmount.Title       = vTitle;
                    lCheeseAmount.Description = vDescription;
                    lCheeseAmount.Price       = vPrice;
                    lCheeseAmount.BizPrice    = vBizPrice;
                    lCheeseAmount.ProductId   = vProductID;
                    lCheeseAmount.AddedDate   = vAddedDate;
                    lCheeseAmount.AddedBy     = vAddedBy;
                    lCheeseAmount.UpdatedDate = vUpdatedDate;
                    lCheeseAmount.UpdatedBy   = vUpdatedBy;
                    lCheeseAmount.Active      = vActive;
                    return(AddCheeseAmount(lCheeseAmount));
                }
            }
        }
Пример #2
0
 private bool ChangeLockState(CheeseAmount vCheeseAmount, bool vState)
 {
     using (FRShoppingEntities frenty = new FRShoppingEntities())
     {
         CheeseAmount up = frenty.CheeseAmounts.FirstOrDefault(e => e.CheeseAmountId == vCheeseAmount.CheeseAmountId);
         up.UpdatedDate = DateTime.Now;
         up.Active      = vState;
         return(frenty.SaveChanges() > 0 ? true : false);
     }
 }
Пример #3
0
        public CheeseAmount AddCheeseAmount(CheeseAmount vCheeseAmount)
        {
            try
            {
                Shoppingctx.CheeseAmounts.Add(vCheeseAmount);
                base.PurgeCacheItems(CacheKey);

                return(Shoppingctx.SaveChanges() > 0 ? vCheeseAmount : null);
            }
            catch
            {
                return(null);
            }
        }
Пример #4
0
        public ActionResult UpdateSharedCart(AddItemModel model, ShoppingCart cart)
        {
            HandleCart(cart);
            model.BizInfo = BizInfoRepository.GetBizInfoById(cart.BizId);
            if (model.BizInfo == null)
            {
                return(Redirect("~/RedirectPage.htm"));
            }

            cart.DriverTip = 0.0m;
            List <CheckBoxViewModel>    selectedFreeToppings = new List <CheckBoxViewModel>();
            List <CheckBoxViewModel>    selectedToppings     = new List <CheckBoxViewModel>();
            List <CheckBoxViewModel>    selectedDressings    = new List <CheckBoxViewModel>();
            List <AddSideCheckBoxModel> selectedAddSides     = new List <AddSideCheckBoxModel>();
            Product prod = ProductRepository.GetProductById(model.ProductID);

            selectedFreeToppings = model.FreeToppingAssistances.Where(e => e.Checked == true).ToList();
            selectedToppings     = model.ToppingAssistances.Where(e => e.Checked == true).ToList();
            selectedDressings    = model.DressingAssistances.Where(e => e.Checked == true).ToList();
            selectedAddSides     = model.AddSideAssistances.Where(e => e.Checked == true).ToList();

            int     ccID       = string.IsNullOrEmpty(model.CrustChoiceID) ? 0 : int.Parse(model.CrustChoiceID);
            string  ccTitle    = string.Empty;
            decimal ccPrice    = 0.0m;
            decimal ccBizPrice = 0.0m;

            if (ccID > 0)
            {
                CrustChoice cc = CrustChoiceRepository.GetCrustChoiceById(ccID);
                ccTitle    = cc.Title;
                ccPrice    = cc.Price;
                ccBizPrice = cc.BizPrice;
            }
            int     caID       = string.IsNullOrEmpty(model.CheeseAmountID) ? 0 : int.Parse(model.CheeseAmountID);
            string  caTitle    = string.Empty;
            decimal caPrice    = 0.0m;
            decimal caBizPrice = 0.0m;

            if (caID > 0)
            {
                CheeseAmount c = CheeseAmountRepository.GetCheeseAmountById(caID);
                caTitle    = c.Title;
                caPrice    = c.Price;
                caBizPrice = c.BizPrice;
            }
            ProductSize ps         = ProductSizeRepository.GetProductSizeById(int.Parse(string.IsNullOrEmpty(model.ProductSize) ? "0" : model.ProductSize));
            string      psTitle    = ps == null ? string.Empty : ps.Title;
            string      pSize      = ps == null ? string.Empty : ps.Size.ToString();
            decimal     psPrice    = ps == null ? 0.0m : ps.Price;
            decimal     psBizPrice = ps == null ? 0.0m : ps.BizPrice;

            foreach (var t in selectedToppings)
            {
                decimal exp = 0.0m;
                if (string.IsNullOrEmpty(psTitle) == false)
                {
                    exp        = psTitle.StartsWith("S", true, null) ? t.BoxPrice : (psTitle.StartsWith("M", true, null) ? t.BoxPrice + 0.50m : psTitle.StartsWith("L", true, null) ? t.BoxPrice + 1.00m : t.BoxPrice + 1.50m);
                    t.BoxPrice = exp;
                }
            }
            int    q     = prod.IsFamilyDinner ? model.FamilyQty : model.Quantity;
            string side  = prod.HasSideChoice ? model.SideChoice : string.Empty;
            string sauce = prod.HasSauceChoice ? model.SauceChoice : string.Empty;
            string pt    = prod.MealSectionId == 3 ? "(Lunch)" + prod.Title : prod.Title;
            string sft   = string.Empty;

            foreach (var s in selectedFreeToppings)
            {
                sft = sft + s.BoxName + ", ";
            }
            if (selectedFreeToppings.Count > 0)
            {
                sft = sft.Remove(sft.Length - 2, 2);
            }
            ShoppingCartItem sci = new ShoppingCartItem("9999", model.ProductID, cart.PersonName, q, false, 0, 0, 0, 0, "", "", pt, prod.BizPrice, prod.BizFinalUnitPrice, prod.UnitPrice, prod.FinalUnitPrice, prod.DiscountPercentage,
                                                        prod.SmallImage, model.Instructions, prod.IsSpicy, model.HowSpicy, prod.IsFamilyDinner, side, sauce, psTitle, pSize, psPrice,
                                                        psBizPrice, sft, selectedToppings, selectedDressings, selectedAddSides, model.DressingChoice, ccTitle, ccPrice, ccBizPrice, caTitle, caPrice, caBizPrice);

            bool bl = CanAddGroupItemToCart(cart.CartKey, sci.ItemTotal);

            if (bl)
            {
                cart.InsertItem(model.ProductID, q, cart.PersonName, false, 0, 0, 0, 0, "", "", pt, prod.BizPrice, prod.BizFinalUnitPrice, prod.UnitPrice, prod.FinalUnitPrice, prod.DiscountPercentage,
                                prod.SmallImage, model.Instructions, prod.IsSpicy, model.HowSpicy, prod.IsFamilyDinner, side, sauce, psTitle, pSize, psPrice,
                                psBizPrice, sft, selectedToppings, selectedDressings, selectedAddSides, model.DressingChoice, ccTitle, ccPrice, ccBizPrice, caTitle, caPrice, caBizPrice);
            }
            model.Cart             = cart;
            ViewBag.canadditem     = bl?"y":"n";
            ViewBag.itemid         = bl? cart.Lines.LastOrDefault().ItemId:"";
            ViewBag.quantity       = q.ToString();
            ViewBag.title          = bl? cart.Lines.LastOrDefault().Title:"";
            ViewBag.itemtotal      = bl? cart.Lines.LastOrDefault().ItemTotal.ToString("N2"):"";
            ViewBag.price          = prod.FinalUnitPrice.ToString("N2");
            ViewBag.subtotal       = cart.SubTotal().ToString("N2");
            ViewBag.bizname        = cart.BizName;
            ViewBag.tax            = GroupCart.GroupCarts[cart.CartKey].PartyTax().ToString("N2");
            ViewBag.drivertip      = GroupCart.GroupCarts[cart.CartKey].PartyDriverTip().ToString("N2");
            ViewBag.globalsubtotal = GroupCart.GroupCarts[cart.CartKey].PartySubTotal().ToString("N2");
            ViewBag.globaltotal    = GroupCart.GroupCarts[cart.CartKey].PartyTotal().ToString("N2");

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

            if (isBoss)
            {
                btnShow = "off";
            }
            else 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";
            }
            ViewBag.btnshow = btnShow;

            SharedShoppingCart ssc = new SharedShoppingCart();

            if (string.IsNullOrEmpty(cart.CartKey) == false)
            {
                ssc = GetGroupShoppingCart(cart.CartKey);
            }
            model.SharedCart = ssc;
            return(PartialView(model));
        }
Пример #5
0
        public ActionResult UpdateCart(AddItemModel model, ShoppingCart cart)
        {
            HandleCart(cart);
            model.BizInfo = BizInfoRepository.GetBizInfoById(cart.BizId);
            if (model.BizInfo == null)
            {
                return(Redirect("~/RedirectPage.htm"));
            }

            cart.DriverTip = 0.0m;
            List <CheckBoxViewModel>    selectedFreeToppings = new List <CheckBoxViewModel>();
            List <CheckBoxViewModel>    selectedToppings     = new List <CheckBoxViewModel>();
            List <CheckBoxViewModel>    selectedDressings    = new List <CheckBoxViewModel>();
            List <AddSideCheckBoxModel> selectedAddSides     = new List <AddSideCheckBoxModel>();
            Product prod = ProductRepository.GetProductById(model.ProductID);

            selectedFreeToppings = model.FreeToppingAssistances.Where(e => e.Checked == true).ToList();
            selectedToppings     = model.ToppingAssistances.Where(e => e.Checked == true).ToList();
            selectedDressings    = model.DressingAssistances.Where(e => e.Checked == true).ToList();
            selectedAddSides     = model.AddSideAssistances.Where(e => e.Checked == true).ToList();

            int     ccID       = string.IsNullOrEmpty(model.CrustChoiceID)?0:int.Parse(model.CrustChoiceID);
            string  ccTitle    = string.Empty;
            decimal ccPrice    = 0.0m;
            decimal ccBizPrice = 0.0m;

            if (ccID > 0)
            {
                CrustChoice cc = CrustChoiceRepository.GetCrustChoiceById(ccID);
                ccTitle    = cc.Title;
                ccPrice    = cc.Price;
                ccBizPrice = cc.BizPrice;
            }
            int     caID       = string.IsNullOrEmpty(model.CheeseAmountID) ? 0 : int.Parse(model.CheeseAmountID);
            string  caTitle    = string.Empty;
            decimal caPrice    = 0.0m;
            decimal caBizPrice = 0.0m;

            if (caID > 0)
            {
                CheeseAmount c = CheeseAmountRepository.GetCheeseAmountById(caID);
                caTitle    = c.Title;
                caPrice    = c.Price;
                caBizPrice = c.BizPrice;
            }
            ProductSize ps         = ProductSizeRepository.GetProductSizeById(int.Parse(string.IsNullOrEmpty(model.ProductSize) ? "0" : model.ProductSize));
            string      psTitle    = ps == null ? string.Empty : ps.Title;
            string      pSize      = ps == null ? string.Empty : ps.Size.ToString();
            decimal     psPrice    = ps == null ? 0.0m : ps.Price;
            decimal     psBizPrice = ps == null ? 0.0m : ps.BizPrice;

            foreach (var t in selectedToppings)
            {
                decimal exp = 0.0m;
                if (string.IsNullOrEmpty(psTitle) == false)
                {
                    exp        = psTitle.StartsWith("S", true, null) ? t.BoxPrice : (psTitle.StartsWith("M", true, null) ? t.BoxPrice + t.BoxIncrementValue : psTitle.StartsWith("L", true, null) ? t.BoxPrice + t.BoxIncrementValue * 2 : t.BoxPrice + t.BoxIncrementValue * 3);
                    t.BoxPrice = exp;
                }
            }
            int    q     = prod.IsFamilyDinner ? model.FamilyQty : model.Quantity;
            string side  = prod.HasSideChoice ? model.SideChoice : string.Empty;
            string sauce = prod.HasSauceChoice ? model.SauceChoice : string.Empty;
            string pt    = prod.MealSectionId == 3 ?"(Lunch)" + prod.Title : prod.Title;
            string sft   = string.Empty;

            foreach (var s in selectedFreeToppings)
            {
                sft = sft + s.BoxName + ", ";
            }
            if (selectedFreeToppings.Count > 0)
            {
                sft = sft.Remove(sft.Length - 2, 2);
            }
            cart.InsertItem(model.ProductID, q, cart.PersonName, false, 0, 0, 0, 0, "", "", pt, prod.BizPrice, prod.BizFinalUnitPrice, prod.UnitPrice, prod.FinalUnitPrice, prod.DiscountPercentage,
                            prod.SmallImage, model.Instructions, prod.IsSpicy, model.HowSpicy, prod.IsFamilyDinner, side, sauce, psTitle, pSize, psPrice,
                            psBizPrice, sft, selectedToppings, selectedDressings, selectedAddSides, model.DressingChoice, ccTitle, ccPrice, ccBizPrice, caTitle, caPrice, caBizPrice);
            model.Cart = cart;

            List <DiscountCoupon> ldc = new List <DiscountCoupon>();
            List <FreeItemCoupon> lfc = new List <FreeItemCoupon>();

            if (model.BizInfo.HasDiscountCoupons)
            {
                ldc = DiscountCouponRepository.GetBizDiscountCouponsByMinimum(cart.BizId, cart.SubTotal(), true);
            }
            model.DiscountCouponList = ldc;
            if (model.BizInfo.HasFreeItemCoupons)
            {
                lfc = FreeItemCouponRepository.GetBizFreeItemCouponsByMinimum(cart.BizId, cart.SubTotal(), true);
            }
            model.FreeItemCouponList = lfc;
            ViewBag.items            = cart.TotalItems == 0 ? string.Empty : cart.TotalItems.ToString();
            return(PartialView(model));
        }
Пример #6
0
 public CheeseAmount UpdateCheeseAmount(CheeseAmount vCheeseAmount)
 {
     throw new NotImplementedException();
 }
Пример #7
0
 public bool UnDeleteCheeseAmount(CheeseAmount vCheeseAmount)
 {
     throw new NotImplementedException();
 }
Пример #8
0
 public bool UnlockCheeseAmount(CheeseAmount vCheeseAmount)
 {
     return(ChangeLockState(vCheeseAmount, true));
 }
Пример #9
0
 public bool LockCheeseAmount(CheeseAmount vCheeseAmount)
 {
     return(ChangeLockState(vCheeseAmount, false));
 }