public ActionResult MakeReservation(int id) // id=BizInfoId { BizInfo bi = BizInfoRepository.GetBizInfoById(id); ViewBag.biztitle = bi.BizTitle; ViewBag.imgUrl = bi.ImageUrl; BizRVInfo brv = bi.GetBizRVInfo; ViewBag.maplink = GoogleMapLink(bi); return(PartialView(brv)); }
public ActionResult AddReview(int id, ShoppingCart cart) { RatingViewModel rvm = new RatingViewModel(); if (id > 0) { rvm.BizInfo = BizInfoRepository.GetBizInfoById(id); } string rul = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.UrlReferrer.PathAndQuery; rvm.ReturnUrl = rul; ViewBag.bagitems = GetCartItems(cart); return(View(rvm)); }
public ActionResult ProcessGroupSchedule(string schedule, string time, ShoppingCart cart) { HandleCart(cart); BizInfo bi = BizInfoRepository.GetBizInfoById(cart.BizId); bool isopen = SearchFilter.IsOpenAt(bi, int.Parse(schedule), time); cart.ScheduleDate = schedule == "2" ? "Tomorrow" : "Today"; cart.ScheduleTime = time; GroupCart.GroupCarts[cart.CartKey].PartyScheduleDate = cart.ScheduleDate; GroupCart.GroupCarts[cart.CartKey].PartyScheduleTime = cart.ScheduleTime; return(Json(new { schDate = cart.ScheduleDate, schTime = cart.ScheduleTime, result = isopen ? "success" : "failed" })); }
public ActionResult GetCart(ShoppingCart cart) { BizInfo bi = BizInfoRepository.GetBizInfoById(cart.BizId); string timeout = "timein"; if (bi == null) { timeout = "timeout"; return(Json(new { timeexp = timeout })); } decimal cartTotal = cart == null ? 0.00m : cart.Total(); decimal ordermin = cart == null ? 0.00m : cart.OrderMinimum; string btnShow = "show"; if (cart.Lines.Sum(x => x.Quantity) == 0 || (cart.OrderMinimum > cart.SubTotal() && cart.IsDelivery) || (bi.Delivery == false && cart.IsDelivery)) { btnShow = "off"; } return(Json(new { bizid = cart.BizId.ToString(), biztitle = bi.BizTitle, bizimg = Url.Content("~/Content/BizImages/" + bi.ImageUrl), bizaddress = bi.BizTwoLineAddressString, bizlink = "/Restaurants/Menu/" + cart.BizId, isbizdelivery = cart.IsBizDelivery ? "yes" : "no", isDelivery = cart.IsDelivery ? "Delivery" : "Pickup", deliverymin = ordermin > 0.0m ? ToUSD(ordermin.ToString("N2")) : "", total = ToUSD(cartTotal.ToString("N2")), cartitems = cart.TotalItems.ToString(), subtotal = ToUSD(cart.SubTotal().ToString("N2")), btnshow = btnShow, timeexp = timeout })); }
public ActionResult ShowThemeChart(int id) { BizInfo p = BizInfoRepository.GetBizInfoById(id); var myChart = new System.Web.Helpers.Chart(width: 200, height: 160, theme: ChartTheme.Green) .AddTitle(p.AverageRating.ToString() + " out of 5 stars") .AddSeries( name: "Reviews", xValue: new[] { "5 Star(" + p.FiveStarVotes.ToString() + "):", "4 Star(" + p.FourStarVotes.ToString() + "):", "3 Star(" + p.ThreeStarVotes.ToString() + "):", "2 Star(" + p.TwoStarVotes.ToString() + "):", "1 Star(" + p.OneStarVotes.ToString() + "):" }, yValues: new[] { (p.FiveStarVotes * 5).ToString(), (p.FourStarVotes * 4).ToString(), (p.ThreeStarVotes * 3).ToString(), (p.TwoStarVotes * 2).ToString(), p.OneStarVotes.ToString() }) .GetBytes("png"); return(File(myChart, "image/png")); }
public ActionResult FaxOrder(int id, int orderid) // id=BizInfoId { string result = "Fax failed!"; if (id > 0 && orderid > 0) { Order od = OrderRepository.GetOrderById(orderid); EmailManager em = new EmailManager(); em.FaxBody = EmailManager.BuildOrderFaxBody(od); em.SendOrderFax(od.BizInfo.Fax); if (em.IsFaxSent) { BizInfo bi = BizInfoRepository.GetBizInfoById(id); result = "Order(id=<b>" + orderid + "</b>) " + "has been successfully faxed to <b>" + bi.BizTitle + "</b>"; } } ViewBag.faxnote = result; return(PartialView()); }
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 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)); }
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)); }