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)); }
public ActionResult Menu(ShoppingCart cart, BrowseHistory bh, int id = 0, int reorderid = 0) { if (cart == null) { ControllerContext cc = new ControllerContext(); cart = new ShoppingCart(); cc.HttpContext.Session["ShoppingCart"] = cart; return(Redirect("/Home")); } if (bh == null) { ControllerContext cc = new ControllerContext(); bh = new BrowseHistory(); bh.IsDelivery = true; cc.HttpContext.Session["BorseHistory"] = bh; return(Redirect("~/Home")); } if (string.IsNullOrEmpty(cart.CartKey) == false && string.IsNullOrEmpty(cart.BossName) == false) { return(Redirect("~/Group")); } if (id == 0) { return(Redirect("~/Home")); } if (cart.BizId != id) { cart.Clear(); cart.IsDelivery = bh.IsDelivery; cart.BizId = id; } if (reorderid > 0) { cart.Clear(); SetupReorder(reorderid, cart, bh); } MenuViewModel mvm = new MenuViewModel(); mvm.BizInfo = BizInfoRepository.GetBizInfoById(id); BizInfo bi = mvm.BizInfo; cart.BizName = bi.BizTitle; StringBuilder sb = new StringBuilder(); sb.Append("["); sb.Append("["); sb.Append("'" + bi.BizTitle + "',"); sb.Append("'" + bi.Address.AddressLine + "',"); sb.Append("'" + bi.Address.City + "',"); sb.Append("'" + bi.Address.State + "',"); sb.Append("'" + bi.Address.ZipCode + "',"); sb.Append("'" + bi.Latitude + "',"); sb.Append("'" + bi.Longitude + "',"); sb.Append("'" + bi.BizInfoId + "',"); sb.Append("'" + bi.ImageUrl + "'],"); sb.Remove(sb.Length - 1, 1); sb.Append("]"); mvm.MapMarkers = sb.ToString(); mvm.Maplink = GoogleMapLink(bi); cart.IsBizDelivery = mvm.BizInfo.Delivery; cart.TaxRate = mvm.BizInfo.TaxPercentageRate; cart.OrderMinimum = mvm.BizInfo.DeliveryMinimum; cart.DeliveryFee = mvm.BizInfo.DeliveryFee; mvm.Cart = cart; mvm.Cart.IsDelivery = bh.IsDelivery; mvm.Cart.BizId = id; mvm.Cart.DeliveryFee = mvm.BizInfo.DeliveryFee; mvm.Cart.OrderMinimum = mvm.BizInfo.DeliveryMinimum; mvm.Cart.BizName = mvm.BizInfo.BizTitle; mvm.History = bh; string rul = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.UrlReferrer.PathAndQuery; mvm.ReturnUrl = rul; mvm.MenuList = BizInfoRepository.GetBizCuisinesByBizInfoId(id, true).ToList(); mvm.FirstSubmenu = mvm.MenuList.FirstOrDefault(); List <DiscountCoupon> ldc = new List <DiscountCoupon>(); List <FreeItemCoupon> lfc = new List <FreeItemCoupon>(); if (mvm.BizInfo.HasDiscountCoupons) { ldc = DiscountCouponRepository.GetBizDiscountCouponsByMinimum(id, cart.SubTotal(), true); } mvm.DiscountCouponList = ldc; if (mvm.BizInfo.HasFreeItemCoupons) { lfc = FreeItemCouponRepository.GetBizFreeItemCouponsByMinimum(id, cart.SubTotal(), true); } mvm.FreeItemCouponList = lfc; ViewBag.rurl = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.Url.PathAndQuery; mvm.ProductsWithImage = ProductRepository.GetAllProductsByBizInfoId(bi.BizInfoId, true).Where(e => string.IsNullOrEmpty(e.SmallImage) == false && e.SmallImage.StartsWith("imageSoon", true, null) == false).ToList(); mvm.BizImages = bi.BizImages.Where(e => string.IsNullOrEmpty(e.SmallImageName) == false && e.SmallImageName.StartsWith("imageSoon", true, null) == false && e.Active == true).ToList(); ViewBag.bagitems = GetCartItems(cart); return(View(mvm)); }