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)); }
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); }
public ActionResult RemoveFromCart(ShoppingCart cart, string itemId) { HandleCart(cart); AddItemModel model = new AddItemModel(); ViewBag.cando = string.IsNullOrEmpty(cart.CartKey) ? "n" : "y"; model.BizInfo = BizInfoRepository.GetBizInfoById(cart.BizId); if (model.BizInfo == null) { return(Redirect("~/Home")); } SharedShoppingCart ssc = new SharedShoppingCart(); if (string.IsNullOrEmpty(cart.CartKey)) { model.SharedCart = ssc; model.Cart = cart; ViewBag.canremoveitem = "n"; return(PartialView(model)); } ssc = GetGroupShoppingCart(cart.CartKey); bool bl = (string.IsNullOrEmpty(itemId) == false && !ssc.IsSharedCartLocked); if (bl) { cart.DeleteProduct(itemId); } ViewBag.canremoveitem = bl?"y":"n"; ViewBag.itemid = itemId; ViewBag.subtotal = cart.SubTotal().ToString("N2"); ViewBag.tax = GroupCart.GroupCarts[cart.CartKey].PartyTax().ToString("N2"); ViewBag.globalsubtotal = GroupCart.GroupCarts[cart.CartKey].PartySubTotal().ToString("N2"); ViewBag.drivertip = GroupCart.GroupCarts[cart.CartKey].PartyDriverTip().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; model.SharedCart = ssc; model.Cart = cart; return(PartialView(model)); }
public SharedShoppingCart GetSharedCart(string cartkey) { if (HttpContext.Application[cartkey] == null) { SharedShoppingCart ssc = new SharedShoppingCart(); ssc.SharedCartKey = cartkey; HttpContext.Application.Lock(); HttpContext.Application[cartkey] = ssc; HttpContext.Application.UnLock(); } return((SharedShoppingCart)HttpContext.Application[cartkey]); }
public ActionResult AddToSharedCart(int id, ShoppingCart cart) { AddItemModel model = new AddItemModel(); ViewBag.canAdd = string.IsNullOrEmpty(cart.CartKey) ? "n" : "y"; model.Product = ProductRepository.GetProductById(id); model.ProductID = id; List <ProductSize> lps = ProductSizeRepository.GetProductSizesByProductId(true, id); model.SizeAssistances = new List <SelectListItem>(); foreach (var s in lps) { model.SizeAssistances.Add(new SelectListItem { Text = s.Title + string.Format(" {0}{1}", s.Size > 0 ? " " + s.Size + "\"" : "", " ($" + s.Price.ToString("N2") + ")"), Value = s.ProductSizeId.ToString() }); } List <ProductTopping> lpt = new List <ProductTopping>(); lpt = ProductToppingRepository.GetProductToppingsByProductId(true, id); foreach (var t in lpt) { model.ToppingAssistances.Add(new CheckBoxViewModel { BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, Checked = false }); } if (model.Product.MaxNumOfFreeTopping > 0) { foreach (var t in lpt) { model.FreeToppingAssistances.Add(new CheckBoxViewModel { BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, Checked = false }); } } List <AddSide> las = new List <AddSide>(); las = model.Product.AddSides.Where(e => e.Active == true).ToList(); foreach (var a in las) { model.AddSideAssistances.Add(new AddSideCheckBoxModel { BoxName = a.Title, BoxPrice = a.Price, BoxBizPrice = a.BizPrice, Checked = false }); } SharedShoppingCart ssc = new SharedShoppingCart(); if (string.IsNullOrEmpty(cart.CartKey) == false) { ssc = GetGroupShoppingCart(cart.CartKey); } model.SharedCart = ssc; model.Cart = cart; return(PartialView(model)); }
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); }
protected void GroupCleanup(ShoppingCart cart) { if (string.IsNullOrEmpty(cart.CartKey) == false) { string ck = cart.CartKey; GroupCart.GroupCarts[cart.CartKey].Clear(); SharedShoppingCart ssc = new SharedShoppingCart(); if (GroupCart.GroupCarts.TryRemove(ck, out ssc)) { } MyInfo = null; } }
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 })); }
public ActionResult Index(ShoppingCart cart, BrowseHistory bh) { HandleCart(cart); GroupCheckoutModel gcm = new GroupCheckoutModel(); SharedShoppingCart ssc = new SharedShoppingCart(); if (string.IsNullOrEmpty(cart.CartKey) == false) { ssc = GetGroupShoppingCart(cart.CartKey); } 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)) { return(Redirect("~/Group"));; } gcm.AddressLine = bh.Address; gcm.City = bh.City; gcm.State = string.IsNullOrEmpty(bh.State) ? "CA" : bh.State; gcm.ZipCode = bh.Zip; if (User.Identity.IsAuthenticated) { UserDetail ud = UserDetailRepository.GetUserDetailByUserId(CurrentUserID); if (ud != null) { gcm.FirstName = ud.FirstName; gcm.LastName = ud.LastName; gcm.AddressLine = string.IsNullOrEmpty(bh.Address)? ud.Address.AddressLine:bh.Address; gcm.City = string.IsNullOrEmpty(bh.City) ? ud.Address.City : bh.City; gcm.State = string.IsNullOrEmpty(bh.State) ? ud.Address.State : bh.State; gcm.ZipCode = string.IsNullOrEmpty(bh.Zip) ? ud.Address.ZipCode : bh.Zip; gcm.Phone = ud.ContactInfo.Phone; gcm.Email = ud.ContactInfo.Email; } } ssc.PartyScheduleDate = GroupCart.GroupCarts[cart.CartKey].PartyScheduleDate; ssc.PartyScheduleTime = GroupCart.GroupCarts[cart.CartKey].PartyScheduleTime; gcm.GroupCheckoutCart = ssc; return(View(gcm)); }
public ActionResult GoGroup(string name, string address, string zip, int bizid, decimal maxorder, ShoppingCart cart, BrowseHistory bh) { string cartkey = Guid.NewGuid().ToString(); if (cart.BizId != bizid) { cart.Clear(); BizInfo bi = BizInfoRepository.GetBizInfoById(bizid); cart.BizId = bizid; cart.IsBizDelivery = bi.Delivery; cart.TaxRate = bi.TaxPercentageRate; cart.OrderMinimum = bi.DeliveryMinimum; cart.DeliveryFee = bi.DeliveryFee; cart.BizName = bi.BizTitle; } MySharedCartId = cartkey; MyLabel = name; MyInfo.BossName = name; MyInfo.MyLabelName = name; MyInfo.SharedCartId = cartkey; cart.BossName = name; cart.CartKey = cartkey; cart.PersonName = name; cart.IsFinishedShareOrdering = false; SharedShoppingCart ssc = new SharedShoppingCart(); ssc.MaxOrder = maxorder <= 0.0m ? 999999.0m : maxorder; ssc.PartyBossName = name; ssc.SharedCartKey = cartkey; ssc.PartyAddress = address + " " + zip; ssc.PartyZip = zip; ssc.IsSharedCartLocked = false; ssc.PartyCart.Add(name, cart); ssc.SelectBizInfos = bh == null ? new List <BizInfo>() : bh.GroupBizOption; SetGroupShoppingCart(cartkey, ssc); string url = Url.Action("Share", new { groupid = cartkey, bizid = bizid }); return(Redirect(url)); }
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 })); }
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)); }
public void SetGroupShoppingCart(string cartkey, SharedShoppingCart cart) { GroupCart.GroupCarts[cartkey] = cart; }
public static SharedShoppingCart GetCopyOfSharedShoppingCart(SharedShoppingCart fromSharedCart) { SharedShoppingCart ssc = new SharedShoppingCart(); Dictionary <string, ShoppingCart> partycart = new Dictionary <string, ShoppingCart>(); foreach (var k in fromSharedCart.PartyCart.Keys) { ShoppingCart fromcart = fromSharedCart.PartyCart[k]; ShoppingCart cart = new ShoppingCart(); foreach (var ci in fromSharedCart.PartyCart[k].Items) { ShoppingCartItem sci = new ShoppingCartItem(); sci.LabelName = k; sci.ItemId = ci.ItemId; sci.ID = ci.ID; sci.Quantity = ci.Quantity; sci.ProductSize = ci.ProductSize; sci.IsReorderItem = ci.IsReorderItem; sci.ReExtraPriceTotal = ci.ReExtraPriceTotal; sci.ReAddSideTotal = ci.ReAddSideTotal; sci.ReBizAddSideTotal = ci.ReBizAddSideTotal; sci.ReItemTotal = ci.ReItemTotal; sci.ReSelectedToppings = ci.ReSelectedToppings; sci.ReSelectedAddSides = ci.ReSelectedAddSides; sci.Title = ci.Title; sci.BizSizePrice = ci.BizSizePrice; sci.BizUnitPrice = ci.BizUnitPrice; sci.BizFinalPrice = ci.BizFinalPrice; sci.UnitPrice = ci.UnitPrice; sci.FinalPrice = ci.FinalPrice; sci.CrustChoice = ci.CrustChoice; sci.CrustChoicePrice = ci.CrustChoicePrice; sci.CrustChoiceBizPrice = ci.CrustChoiceBizPrice; sci.CheeseChoice = ci.CheeseChoice; sci.CheeseChoicePrice = ci.CheeseChoicePrice; sci.CheeseChoiceBizPrice = ci.CheeseChoiceBizPrice; sci.DiscountPercentage = ci.DiscountPercentage; sci.ProductImg = ci.ProductImg; sci.Instruction = ci.Instruction; sci.IsSpicy = ci.IsSpicy; sci.HowSpicy = ci.HowSpicy; sci.IsFamilyMeal = ci.IsFamilyMeal; sci.SelectedFreeToppings = ci.SelectedFreeToppings; sci.SideChoice = ci.SideChoice; sci.SauceChoice = ci.SauceChoice; sci.DressingChoice = ci.DressingChoice; sci.ProductSizeTitle = ci.ProductSizeTitle; sci.ProductSizePrice = ci.ProductSizePrice; sci.ToppingList = ci.ToppingList; sci.DressingList = ci.DressingList; sci.AddSideList = ci.AddSideList; cart.Items.Add(sci); } cart.PersonName = fromcart.PersonName; cart.CartKey = fromcart.CartKey; cart.BossName = fromcart.BossName; cart.ItemNum = fromcart.ItemNum; cart.BizId = fromcart.BizId; cart.IsFinishedShareOrdering = fromcart.IsFinishedShareOrdering; cart.ScheduleDate = fromcart.ScheduleDate; cart.ScheduleTime = fromcart.ScheduleTime; cart.IsBizDelivery = fromcart.IsBizDelivery; cart.IsDelivery = fromcart.IsDelivery; cart.FreeCoupon = fromcart.FreeCoupon; cart.FreeItem = fromcart.FreeItem; cart.DiscountCoupon = fromcart.DiscountCoupon; cart.DiscountPercentage = fromcart.DiscountPercentage; cart.CouponChoice = fromcart.CouponChoice; cart.CurrentDiscountMini = fromcart.CurrentDiscountMini; cart.TaxRate = fromcart.TaxRate; cart.OrderMinimum = fromcart.OrderMinimum; cart.DeliveryFee = fromcart.DeliveryFee; cart.DriverTip = fromcart.DriverTip; partycart.Add(k, cart); } ssc.PartyCart = partycart; ssc.SharedCartKey = fromSharedCart.SharedCartKey; ssc.IsSharedCartLocked = fromSharedCart.IsSharedCartLocked; ssc.PartyBossName = fromSharedCart.PartyBossName; ssc.PartyItemNum = fromSharedCart.PartyItemNum; // ssc.BizId = fromSharedCart.BizId; ssc.PartyScheduleDate = fromSharedCart.PartyScheduleDate; ssc.PartyScheduleTime = fromSharedCart.PartyScheduleTime; //ssc.IsBizDelivery = fromSharedCart.IsBizDelivery; ssc.IsPartyDelivery = fromSharedCart.IsPartyDelivery; ssc.PartyFreeCoupon = fromSharedCart.PartyFreeCoupon; ssc.PartyFreeItem = fromSharedCart.PartyFreeItem; ssc.PartyDiscountCoupon = fromSharedCart.PartyDiscountCoupon; ssc.PartyDiscountPercentage = fromSharedCart.PartyDiscountPercentage; ssc.PartyCouponChoice = fromSharedCart.PartyCouponChoice; ssc.PartyCurrentDiscountMini = fromSharedCart.PartyCurrentDiscountMini; // ssc.PartyDeliveryFee = fromSharedCart.PartyDeliveryFee; // ssc.PartyDriverTip = fromSharedCart.PartyDriverTip; // ssc.PartyOrderMinimum = fromSharedCart.PartyOrderMinimum; ssc.PartyTaxRate = fromSharedCart.PartyTaxRate; return(ssc); }
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")) })); }
public void SetSharedCart(string cartkey, SharedShoppingCart cart) { HttpContext.Application.Lock(); HttpContext.Application[cartkey] = cart; HttpContext.Application.UnLock(); }
public ActionResult Share(string groupid, ShoppingCart cart, BrowseHistory bh, int bizid = 0) { if (bh == null) { ControllerContext cc = new ControllerContext(); bh = new BrowseHistory(); bh.IsDelivery = true; cc.HttpContext.Session["BorseHistory"] = bh; return(Redirect("~/Group")); } if (string.IsNullOrEmpty(groupid)) { return(Redirect("~/Group")); } if (GroupCart.GroupCarts.ContainsKey(groupid) == false || bizid <= 0) { return(Redirect("~/Group")); } if ((GroupCart.GroupCarts[groupid].IsSharedCartLocked && GroupCart.GroupCarts[groupid].PartyBossName != cart.PersonName)) { return(Redirect("~/Group")); } BizInfo bi = GroupCart.GroupCarts[groupid].SelectBizInfos.Where(e => e.BizInfoId == bizid).FirstOrDefault(); if (bi == null) { return(Redirect("~/Group")); } if (bizid != cart.BizId) { MyInfo.BossName = GroupCart.GroupCarts[groupid].PartyBossName;; MyInfo.MyLabelName = cart.PersonName; cart.Clear(); cart.BossName = MyInfo.BossName; cart.CartKey = groupid; cart.PersonName = MyInfo.MyLabelName; cart.IsFinishedShareOrdering = false; cart.BizId = bizid; cart.IsBizDelivery = bi.Delivery; cart.TaxRate = bi.TaxPercentageRate; cart.OrderMinimum = bi.DeliveryMinimum; cart.DeliveryFee = bi.DeliveryFee; cart.BizName = bi.BizTitle; } ViewBag.cartkey = groupid; cart.IsFinishedShareOrdering = false; SharedShoppingCart ssc = new SharedShoppingCart(); ssc = GetGroupShoppingCart(groupid); //ssc.IsPartyDelivery = ssc.PartyCart[ssc.PartyBossName].IsBizDelivery; ViewBag.bossname = ssc.PartyBossName; ViewBag.myname = MyLabel; ViewBag.isBoss = ssc.PartyBossName == cart.PersonName ? "yes" : "no"; ViewBag.bizinfoid = bizid; ViewBag.bizname = bi.BizTitle; ShareMenuViewModel smvm = new ShareMenuViewModel(); smvm.Cart = cart; smvm.SharedCart = ssc; smvm.Cart.IsDelivery = ssc.IsPartyDelivery; smvm.History = bh; smvm.BizInfo = bi; string rul = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.UrlReferrer.PathAndQuery; smvm.ReturnUrl = rul; smvm.MenuList = BizInfoRepository.GetBizCuisinesByBizInfoId(cart.BizId, true).ToList(); smvm.FirstSubmenu = smvm.MenuList.FirstOrDefault(); ViewBag.rurl = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.Url.PathAndQuery; return(View(smvm)); }