//[OutputCache(Duration = 600, VaryByParam = "id")] public ActionResult City(string id, ShoppingCart cart, BrowseHistory bh) { ViewBag.bagitems = GetCartItems(cart); ViewBag.delivery = bh.IsDelivery; string ct = string.IsNullOrEmpty(id) ? string.Empty : DecodeString(id); CityModel cm = new CityModel(); cm.CityName = ct; cm.YelpTops = new List <TopYelpModel>(); if ((HttpContext.Cache["CityTops_" + id] != null)) { cm.YelpTops = (List <TopYelpModel>)HttpContext.Cache["CityTops_" + id]; } else { List <BizInfo> lbi = BizInfoRepository.GetBizInfoByCity(ct, true); YelpReviewModel yrm = new YelpReviewModel(); foreach (var b in lbi) { yrm = YelpBizDetails.GetYelpBiz(b); if (string.IsNullOrEmpty(b.YelpBizId) == false) { cm.YelpTops.Add(new TopYelpModel() { Biz = b, Yelp = yrm }); } } cm.YelpTops = cm.YelpTops.OrderByDescending(e => e.Yelp.Biz.rating).Take(3).ToList(); HttpContext.Cache.Insert("CityTops_" + id, cm.YelpTops); } //cm.BizInfos = BizInfoRepository.GetTopnTopRatedBizInfosInCity(3, ct, true); cm.NewBiz = BizInfoRepository.GetLastnNewBizInfosByCity(4, ct, true); StringBuilder sb = new StringBuilder(); sb.Append("["); foreach (var b in cm.YelpTops) { sb.Append("["); sb.Append("'" + b.Biz.BizTitle + "',"); sb.Append("'" + b.Biz.Address.AddressLine + "',"); sb.Append("'" + b.Biz.Address.City + "',"); sb.Append("'" + b.Biz.Address.State + "',"); sb.Append("'" + b.Biz.Address.ZipCode + "',"); sb.Append("'" + b.Biz.Latitude + "',"); sb.Append("'" + b.Biz.Longitude + "',"); sb.Append("'" + b.Biz.BizInfoId + "',"); sb.Append("'" + b.Biz.ImageUrl + "'],"); } if (cm.YelpTops.Count > 0) { sb.Remove(sb.Length - 1, 1); } sb.Append("]"); cm.MapMarkers = sb.ToString(); cm.BizInfo = BizInfoRepository.GetBizInfoByCity(ct, true).FirstOrDefault(); cm.ShowCuisines = AllCuisinesView.ShowCuisinesView_Bootatrap(BizCuisineRepository.GetBizCuisinesByCity(true, ct), ct, null); cm.ShowZipcodes = AllZopCodesView.ShowZipCodesView_Bootstarp(BizInfoRepository.GetBizInfoByCity(ct, true), ct, null); cm.CuisinesInCity = BizInfoRepository.GetCuisinesInCity(ct); cm.ZipsInCity = BizInfoRepository.GetZipsInCity(ct); return(View(cm)); }
public ActionResult Index(string city, string zip, ShoppingCart cart, BrowseHistory bh) { if (string.IsNullOrEmpty(city) && string.IsNullOrEmpty(zip)) { return(RedirectToAction("Index", "AllCities")); } ViewBag.delivery = bh.IsDelivery; BizInfoModel bim = new BizInfoModel(); string ct = string.IsNullOrEmpty(city)?string.Empty : DecodeString(city); bim.CityName = ct; bim.ZipCode = zip; bim.BizInfos = BizInfoRepository.GetBizInfoByZip(zip, true); bim.YelpTops = new List <TopYelpModel>(); if ((HttpContext.Cache["CityZip" + ct + zip] != null)) { bim.YelpTops = (List <TopYelpModel>)HttpContext.Cache["CityZip" + ct + zip]; } else { YelpReviewModel yrm = new YelpReviewModel(); foreach (var b in bim.BizInfos) { yrm = YelpBizDetails.GetYelpBiz(b); if (string.IsNullOrEmpty(b.YelpBizId) == false) { bim.YelpTops.Add(new TopYelpModel() { Biz = b, Yelp = yrm }); } } bim.YelpTops = bim.YelpTops.OrderByDescending(e => e.Yelp.Biz.rating).Take(3).ToList(); HttpContext.Cache.Insert("CityZip" + ct + zip, bim.YelpTops); } // bim.TopRatedBizInfos = BizInfoRepository.GetTopnTopRatedBizInfosInzip(3, zip, true); bim.BizInfo = bim.BizInfos.FirstOrDefault(); bim.NewBiz = BizInfoRepository.GetLastnNewBizInfosByZip(4, zip, true); bim.ShowCuisines = AllCuisinesView.ShowCuisinesView_Bootatrap(BizCuisineRepository.GetBizCuisinesByZip(true, zip), ct, zip); StringBuilder sb = new StringBuilder(); sb.Append("["); foreach (var b in bim.YelpTops) { sb.Append("["); sb.Append("'" + b.Biz.BizTitle + "',"); sb.Append("'" + b.Biz.Address.AddressLine + "',"); sb.Append("'" + b.Biz.Address.City + "',"); sb.Append("'" + b.Biz.Address.State + "',"); sb.Append("'" + b.Biz.Address.ZipCode + "',"); sb.Append("'" + b.Biz.Latitude + "',"); sb.Append("'" + b.Biz.Longitude + "',"); sb.Append("'" + b.Biz.BizInfoId + "',"); sb.Append("'" + b.Biz.ImageUrl + "'],"); } if (bim.YelpTops.Count > 0) { sb.Remove(sb.Length - 1, 1); } sb.Append("]"); bim.MapMarkers = sb.ToString(); bim.CuisinesInZip = BizInfoRepository.GetCuisinesInZip(zip); ViewBag.bagitems = GetCartItems(cart); return(View(bim)); }
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 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 DisplayHistory(BrowseHistory bh) { m_history = bh; InitializeComponent(); }
public DisplayHistory(BrowseHistory History) { InitializeComponent(); m_history = History; }
public void SetupReorder(int vReorderid, ShoppingCart vCart, BrowseHistory vBh) { Order od = OrderRepository.GetOrderById(vReorderid); if (od == null) { return; } vBh.AddressCityState = od.Street + ", " + od.City + ", " + od.State; vBh.Address = od.Street; vBh.City = od.City; vBh.State = od.State; vBh.Zip = od.ZipCode; vBh.IsDelivery = od.IsDelivery; foreach (var oi in od.OrderItems) //check if price has been changed { if (oi.FinalSalePrice < oi.Product.FinalUnitPrice) { return; } } vCart.CouponChoice = od.CouponChoice; int discountpercent = 0; if (int.TryParse(vCart.CouponChoice, out discountpercent)) { DiscountCoupon dc = DiscountCouponRepository.GetDiscountCouponsByBizIdPercent(od.BizInfoId, discountpercent, true); if (dc == null) // discount coupon expired { vCart.CouponChoice = ""; return; } vCart.CouponChoice = vCart.CouponChoice; // DiscountPercentage vCart.CurrentDiscountMini = dc == null ? 0.0m : dc.OrderMinimum; //discount order Minimum vCart.DiscountPercentage = discountpercent; vCart.FreeItem = ""; vCart.DiscountCoupon = true; vCart.FreeCoupon = false; } else if (od.CouponChoice == "" || od.CouponChoice == "Apply a coupon? No, Thanks") { vCart.CouponChoice = ""; vCart.CurrentDiscountMini = 999999.0m;//discount order Minimum vCart.DiscountPercentage = 0; vCart.FreeItem = ""; vCart.DiscountCoupon = false; vCart.FreeCoupon = false; } else { vCart.CurrentDiscountMini = 999999.0m;//discount order Minimum vCart.DiscountPercentage = 0; vCart.FreeItem = vCart.CouponChoice; vCart.DiscountCoupon = false; vCart.FreeCoupon = true; } vCart.DriverTip = od.DriverTip; foreach (var oi in od.OrderItems) { vCart.InsertItem(oi.ProductId, oi.Quantity, "", true, oi.ExtraListTotal, oi.AddSideListPrice, oi.BizAddSideListPrice, oi.ItemTotal, oi.SelectedToppings, oi.SelectedAddSides, oi.Title, oi.BizUnitPrice, oi.BizFinalPrice, oi.UnitPrice, oi.FinalSalePrice, oi.DiscountPercentage, oi.Product.SmallImage, oi.Instruction, oi.Product.IsSpicy, oi.HowSpicy, oi.IsFamilyMeal, oi.SideChoice, oi.SauceChoice, oi.ProductSizeTitle, oi.ProductSize, oi.ProductSizePrice, oi.BizSizePrice, oi.SelectedFreeToppings, new List <CheckBoxViewModel>(), new List <CheckBoxViewModel>(), new List <AddSideCheckBoxModel>(), oi.DressingChoice, oi.CrustChoice, oi.CrustChoicePrice, oi.CrustChoiceBizPrice, oi.CheeseAmount, oi.cheeseAmountPrice, oi.CheeseAmountBizPrice); } }
public DisplayHistory(BrowseHistory bh) { InitializeComponent(); m_History = bh; }
public ActionResult SearchSort(string sortParam, BrowseHistory bh) { ViewBag.Address = bh.AddressCityState; ViewBag.Zipcode = bh.Zip; ViewBag.SortParam = sortParam ?? ViewBag.SortParam; string SortParameter = (string)ViewBag.SortParam; FilterViewModels fvm = new FilterViewModels(); fvm.cuisine = bh.Cuisine; // string.IsNullOrEmpty(cuisine) ? fvm.cuisine : cuisine; List <CuisineType> lct = CuisineTypeRepository.GetAllCuisineTypes(true); fvm.CuisineAssistances = new List <SelectListItem>(); fvm.CuisineAssistances.Add(new SelectListItem { Text = "All Cuisines", Value = "All" }); foreach (var c in lct) { fvm.CuisineAssistances.Add(new SelectListItem { Text = c.Title, Value = c.Title }); } fvm.History = bh; fvm.city = bh.City; fvm.zip = bh.Zip; fvm.userFullAddress = bh.AddressCityState + " " + bh.Zip; // fvm.BizInfos = BizInfoRepository.GetAllBizInfos(true); // .Where(p => (string.IsNullOrEmpty(ct) ? true : p.Address.City.ToLower() == ct.ToLower()) // && (string.IsNullOrEmpty(zip) ? true : p.Address.ZipCode == zip) // && (string.IsNullOrEmpty(cuisine) ? true : p.BizCuisines.Where(e=>e.CuisineTypeName==cuisine && e.BizInfoId==p.BizInfoId).Count()>0)).ToList(); fvm.BizInfos = bh.FilterSet; if (SortParameter.StartsWith("BizTitle")) { if (SortParameter != "BizTitle") { fvm.BizOpenSet = bh.FilterOpenSet.OrderBy(e => e.BizTitle).ToList(); fvm.BizCloseSet = bh.FilterCloseSet.OrderBy(e => e.BizTitle).ToList(); fvm.BizHiddenSet = bh.FilterHiddenSet.OrderBy(e => e.BizTitle).ToList(); } else { fvm.BizOpenSet = bh.FilterOpenSet.OrderByDescending(e => e.BizTitle).ToList(); fvm.BizCloseSet = bh.FilterCloseSet.OrderByDescending(e => e.BizTitle).ToList(); fvm.BizHiddenSet = bh.FilterHiddenSet.OrderByDescending(e => e.BizTitle).ToList(); } ViewBag.TitleSortParam = ((string)ViewBag.SortParam == "BizTitle") ? "BizTitle desc" : "BizTitle"; } if (SortParameter.StartsWith("AddedDate")) { if (SortParameter != "AddedDate") { fvm.BizOpenSet = bh.FilterOpenSet.OrderBy(e => e.AddedDate).ToList(); fvm.BizCloseSet = bh.FilterCloseSet.OrderBy(e => e.AddedDate).ToList(); fvm.BizHiddenSet = bh.FilterHiddenSet.OrderBy(e => e.AddedDate).ToList(); } else { fvm.BizOpenSet = bh.FilterOpenSet.OrderByDescending(e => e.AddedDate).ToList(); fvm.BizCloseSet = bh.FilterCloseSet.OrderByDescending(e => e.AddedDate).ToList(); fvm.BizHiddenSet = bh.FilterHiddenSet.OrderByDescending(e => e.AddedDate).ToList(); } ViewBag.NewestSortParam = ((string)ViewBag.SortParam == "AddedDate") ? "AddedDate desc" : "AddedDate"; } bh.FilterOpenSet = fvm.BizOpenSet; bh.FilterCloseSet = fvm.BizCloseSet; bh.FilterHiddenSet = fvm.BizHiddenSet; return(PartialView(fvm)); }
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 FilterUpdate(string schedule, string time, string cuisine, string min, string dist, string rating, string freeDelivery, string breakfast, string lunchSpecial, string coupons, string freeItems, BrowseHistory bh) { string timeout = "timein"; if (bh.FilterSet == null) { timeout = "timeout"; return(Json(new { timeexp = timeout })); } List <BizInfo> openset = new List <BizInfo>(); List <BizInfo> closeset = new List <BizInfo>(); List <BizInfo> hiddenset = new List <BizInfo>(); int[] filterOn = { }; int[] filterOff = { }; int[] filterOpen = { }; string[] localOn = { }; string[] localOff = { }; string[] localOpen = { }; List <int> ltOn = new List <int>(); List <int> ltOpen = new List <int>(); List <int> ltOff = new List <int>(); List <string> ltLocalOn = new List <string>(); List <string> ltLocalOpen = new List <string>(); List <string> ltLocalOff = new List <string>(); int closeCount = 0; YelpReviewModel yrm = new YelpReviewModel(); foreach (var p in bh.FilterSet) { string tm = SearchFilter.ConvertLocalToMyTime(p.BizHour.BizTimeZoneName).ToString(); yrm = YelpBizDetails.GetYelpBiz(p); bool yrating = string.IsNullOrEmpty(rating)?true: int.Parse(rating) <= 0 ? true : yrm.Biz == null?p.AverageRating >= decimal.Parse(rating):yrm.Biz.rating >= double.Parse(rating); if (SearchFilter.ItemFilter(p, schedule, time, cuisine, min, dist, yrating, freeDelivery, breakfast, lunchSpecial, coupons, freeItems, bh)) { ltOn.Add(p.BizInfoId); ltLocalOn.Add(tm); if (p.IsOpenNow) { openset.Add(p); ltOpen.Add(p.BizInfoId); ltLocalOpen.Add(tm); } else { closeset.Add(p); closeCount++; } } else { hiddenset.Add(p); ltOff.Add(p.BizInfoId); ltLocalOff.Add(tm); } } bh.FilterOpenSet = openset; bh.FilterCloseSet = closeset; bh.FilterHiddenSet = hiddenset; filterOn = ltOn.ToArray(); filterOpen = ltOpen.ToArray(); filterOff = ltOff.ToArray(); localOn = ltLocalOn.ToArray(); localOff = ltLocalOff.ToArray(); localOpen = ltLocalOpen.ToArray(); return(Json(new { timeexp = timeout, featherOn = filterOn, featherOnCount = filterOn.Count().ToString(), featherCloseCount = closeCount, featherOpen = filterOpen, featherOpenCount = filterOpen.Count().ToString(), featherOff = filterOff, featherOffCount = filterOff.Count().ToString(), localOn = localOn, localOff = localOff, localOpen = localOpen })); // return Json(new { sch = schedule, dlvtime = time, mini = min, distc = dist, rate = rating, re1 = freeDelivery, re2 = breakfast, re3 = lunchSpecial, re4 = coupons, re5 = freeItems }); }
public static bool ItemFilter(BizInfo vBizInfo, string schedule, string time, string cuisine, string min, string dist, bool yrating, string freeDelivery, string breakfast, string lunchSpecial, string coupons, string freeItems, BrowseHistory bh) { string approxtime = string.Empty; bool hascuisine = string.IsNullOrEmpty(cuisine) ? true : cuisine.ToLower() == "all" ? true : vBizInfo.ContainsCuisine(cuisine); bool isopen = IsOpenAt(vBizInfo, int.Parse(schedule), time); bool delmin = decimal.Parse(min) <= 0.0m ? true : vBizInfo.DeliveryMinimum < decimal.Parse(min); decimal g = GetDistance(bh.FullAddress, vBizInfo, out approxtime); bool distance = decimal.Parse(dist) <= 0.0m ? true : (g < 0.0m ? false : g < decimal.Parse(dist)); bool freedel = freeDelivery == "checked" ? vBizInfo.DeliveryFee <= 0.0m : true; bool hasbreakfast = breakfast == "checked" ? vBizInfo.HasBreakfast : true; bool lunch = lunchSpecial == "checked" ? vBizInfo.HasLunchSpecial : true; bool coupon = coupons == "checked" ? vBizInfo.HasDiscountCoupons : true; bool fitem = freeItems == "checked" ? vBizInfo.HasFreeItemCoupons : true; return(isopen && hascuisine && delmin && distance && yrating && freedel && hasbreakfast && lunch && coupon && fitem); }
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 })); } bh.IsDelivery = del == "true" ? true : false; cart.IsDelivery = bh.IsDelivery; cart.DriverTip = cart.IsDelivery?cart.SubTotal() * 0.15m: 0.00m; string btnShow = "show"; if (cart.Lines.Sum(x => x.Quantity) == 0 || (cart.OrderMinimum > cart.SubTotal() && cart.IsDelivery) || (bi.Delivery == false && cart.IsDelivery)) { btnShow = "off"; } decimal baseint = cart.IsDelivery ? Decimal.Round(cart.SubTotal() * 0.15m) + 1 : 2.0m; string int0 = "<option value='" + baseint.ToString("N2") + "'>" + "$" + baseint.ToString("N2") + " --- tip" + "</option>"; string int1 = "<option value='" + (baseint + 1.00m).ToString("N2") + "'>" + "$" + (baseint + 1.00m).ToString("N2") + " --- tip" + "</option>"; string int2 = "<option value='" + (baseint + 2.00m).ToString("N2") + "'>" + "$" + (baseint + 2.00m).ToString("N2") + " --- tip" + "</option>"; string int3 = "<option value='" + (baseint + 3.00m).ToString("N2") + "'>" + "$" + (baseint + 3.00m).ToString("N2") + " --- tip" + "</option>"; string int4 = "<option value='" + (baseint + 4.00m).ToString("N2") + "'>" + "$" + (baseint + 4.00m).ToString("N2") + " --- tip" + "</option>"; string int5 = "<option value='" + (baseint + 5.00m).ToString("N2") + "'>" + "$" + (baseint + 5.00m).ToString("N2") + " --- tip" + "</option>"; string int6 = "<option value='" + (baseint + 6.00m).ToString("N2") + "'>" + "$" + (baseint + 6.00m).ToString("N2") + " --- tip" + "</option>"; string int7 = "<option value='" + (baseint + 7.00m).ToString("N2") + "'>" + "$" + (baseint + 7.00m).ToString("N2") + " --- tip" + "</option>"; string int8 = "<option value='" + (baseint + 8.00m).ToString("N2") + "'>" + "$" + (baseint + 8.00m).ToString("N2") + " --- tip" + "</option>"; string int9 = "<option value='" + (baseint + 9.00m).ToString("N2") + "'>" + "$" + (baseint + 9.00m).ToString("N2") + " --- tip" + "</option>"; decimal subTotal = cart.SubTotal(); decimal cartTotal = cart.Total(); return(Json(new { timeexp = timeout, delFee = cart.DeliveryFee.ToString("N2"), delMin = cart.OrderMinimum.ToString("N2"), isDelivery = cart.IsDelivery ? "delivery" : "pickup", total = subTotal <= 0 ? "$0.00" : ToUSD(cartTotal.ToString("N2")), subtotal = ToUSD(subTotal.ToString("N2")), basevalue = cart.DriverTip.ToString("N2"), inttip0 = int0, inttip1 = int1, inttip2 = int2, inttip3 = int3, inttip4 = int4, inttip5 = int5, inttip6 = int6, inttip7 = int7, inttip8 = int8, inttip9 = int9, btnshow = btnShow })); }
//This method is used to save navigation history on a disk private void btnSave_Click(object sender, RoutedEventArgs e) { if (LoadTileClicked == true) { BrowseHistory bh = null; try { bh = m_biz.GetFullHistory(); } catch (CommunicationObjectFaultedException) { MessageBox.Show("Error: Connection With the server is lost"); } //Have used save file dialog window to save the file //Save file dialog window is utilized to save in only .xml extensions fileSaveWindow = new SaveFileDialog(); fileSaveWindow.InitialDirectory = "c:\\"; fileSaveWindow.Filter = "XML files (*.xml)|*.xml"; fileSaveWindow.RestoreDirectory = true; //If the save dialog opens up if (fileSaveWindow.ShowDialog() == true && bh != null) { try { //In here checks if the stream is null(Checks if the file is empty to load) if ((myStream2 = fileSaveWindow.OpenFile()) != null) { //Serializing browse history to save it in the xml DataContractSerializer serializer = new DataContractSerializer(typeof(BrowseHistory)); serializer.WriteObject(myStream2, bh); myStream2.Close(); } } //If the file name is empty catch (ArgumentNullException) { MessageBox.Show("Error: File name is empty!"); } //serializer encountering invalid data catch (InvalidDataContractException) { MessageBox.Show("Error: File name is empty!"); } //Error in serialization/De serialization catch (SerializationException) { MessageBox.Show("Error: File name is empty!"); } //Message exceeding quota catch (QuotaExceededException) { MessageBox.Show("Error: Cannot write more data to disk!"); } //If biz tier/data tier program is not up and running yet catch (CommunicationObjectFaultedException) { MessageBox.Show("Error: The server is not responding. Please try again later!"); } } } else { MessageBox.Show("First load tile and navigate through tiles to collect history"); } }
public ActionResult Index(string dlv, string street, string address, string city, string zip, string cuisine, ShoppingCart cart, BrowseHistory bh) { ViewBag.result = "y"; string ct = string.IsNullOrEmpty(city) ? string.Empty : DecodeString(city); bh.City = ct; bh.Address = string.IsNullOrEmpty(street) ? "" : street; bh.AddressCityState = string.IsNullOrEmpty(address) ? "" : address; bh.Zip = zip; bh.Cuisine = string.IsNullOrEmpty(cuisine) ? string.Empty : DecodeString(cuisine); ViewBag.Address = bh.AddressCityState; ViewBag.Zipcode = bh.Zip; bh.IsDelivery = string.IsNullOrEmpty(dlv) ? bh.IsDelivery : (dlv == "true" ? true : false); ViewBag.delivery = bh.IsDelivery; FilterViewModels fvm = new FilterViewModels(); fvm.cuisine = bh.Cuisine; // string.IsNullOrEmpty(cuisine) ? fvm.cuisine : cuisine; List <CuisineType> lct = CuisineTypeRepository.GetAllCuisineTypes(true); fvm.CuisineAssistances = new List <SelectListItem>(); fvm.CuisineAssistances.Add(new SelectListItem { Text = "All Cuisines", Value = "All" }); foreach (var c in lct) { fvm.CuisineAssistances.Add(new SelectListItem { Text = c.Title, Value = c.Title }); } fvm.History = bh; fvm.city = ct; fvm.zip = zip; fvm.userFullAddress = bh.AddressCityState + " " + bh.Zip; fvm.BizInfos = BizInfoRepository.GetAllBizInfos(true) .Where(p => (string.IsNullOrEmpty(ct) ? true : p.Address.City.ToLower() == ct.ToLower()) && (string.IsNullOrEmpty(zip) ? true : p.Address.ZipCode == zip) && (string.IsNullOrEmpty(cuisine) ? true : p.BizCuisines.Where(e => e.CuisineTypeName == bh.Cuisine && e.BizInfoId == p.BizInfoId).Count() > 0)).ToList(); if (fvm.BizInfos == null || fvm.BizInfos.Count <= 0) { ViewBag.result = "n"; return(View(fvm)); } bh.FilterSet = fvm.BizInfos; fvm.BizOpenSet = fvm.BizInfos.Where(e => e.IsOpenNow == true).ToList(); fvm.BizCloseSet = fvm.BizInfos.Except(fvm.BizOpenSet).ToList(); fvm.BizHiddenSet = new List <BizInfo>(); bh.FilterOpenSet = fvm.BizOpenSet; bh.FilterCloseSet = fvm.BizCloseSet; bh.FilterHiddenSet = fvm.BizHiddenSet; StringBuilder sb = new StringBuilder(); sb.Append("["); foreach (var b in fvm.BizInfos) { sb.Append("["); sb.Append("'" + b.BizTitle + "',"); sb.Append("'" + b.Address.AddressLine + "',"); sb.Append("'" + b.Address.City + "',"); sb.Append("'" + b.Address.State + "',"); sb.Append("'" + b.Address.ZipCode + "',"); sb.Append("'" + b.Latitude + "',"); sb.Append("'" + b.Longitude + "',"); sb.Append("'" + b.BizInfoId + "',"); sb.Append("'" + b.ImageUrl + "',"); sb.Append("'" + "tr-" + b.BizInfoId + "'],"); } if (fvm.BizInfos.Count > 0) { sb.Remove(sb.Length - 1, 1); } sb.Append("]"); fvm.MapMarkers = sb.ToString(); ViewBag.bagitems = GetCartItems(cart); return(View(fvm)); }
public DisplayHistory(BrowseHistory hist) { m_history = hist; m_entry = null; InitializeComponent(); }
public ActionResult DiscountList(string vCity, string vZip, ShoppingCart cart, BrowseHistory bh) { DiscountListViewModel dlv = new DiscountListViewModel(); dlv.History = bh; dlv.LBizInfos = BizInfoRepository.GetBizInfosByCityZip(vCity, vZip).Where(e => e.HasDiscountCoupons || e.HasFreeItemCoupons).ToList(); ViewBag.bagitems = GetCartItems(cart); return(View(dlv)); }
public static void UseModelForSinglePrediction(MLContext mlContext, ITransformer model) { OsExtensions.WriteOver($"Processing predictions, pass {Config.CurrentIteration}"); var predictionEngine = mlContext.Model.CreatePredictionEngine <BrowseHistory, BrowsePrediction>(model); foreach (var agent in Agents) { var recs = new List <BrowsePrediction>(); for (var i = 1; i < 500000; i++) { var testInput = new BrowseHistory { userId = agent.Id, itemId = i }; var itemPrediction = predictionEngine.Predict(testInput); itemPrediction.Iteration = Config.CurrentIteration; itemPrediction.UserId = testInput.userId; itemPrediction.ItemId = testInput.itemId; if (Math.Round(itemPrediction.Score, 1) > 3.5) { var site = Sites.FirstOrDefault(o => o.Id == itemPrediction.ItemId); if (site == null) { continue; } if (agent.Preference == site.Category) { // add matching sites with positive correlation itemPrediction.Score = 5; recs.Add(itemPrediction); //results.Add($"Item {testInput.itemId} is recommended for user {testInput.userId} at {Math.Round(itemPrediction.Score, 1)}"); } else { // add but rate as poor match itemPrediction.Score = 1; recs.Add(itemPrediction); } } } using (StreamWriter w = File.AppendText(Config.OutputFile)) { //var rnd = new Random(); //var choices = recs.OrderBy(x => rnd.Next()).Take(25); var choices = recs; foreach (var rec in choices) { TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); int secondsSinceEpoch = (int)t.TotalSeconds; w.WriteLine($"{rec.UserId},{rec.ItemId},{Math.Round(rec.Score, 1)},{secondsSinceEpoch},{rec.Iteration}"); //user_id,item_id,timestamp } } } }
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 ListIterator(BrowseHistory browseHistory) { _browseHistory = browseHistory; }
static void Main(string[] args) { Console.WriteLine("Enter 1 for Factory Pattern. \n" + "Enter 2 for Observer Pattern."); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: var ef = new EmployeeFactory(); Console.WriteLine(ef.GetEmployee(1).GetBonus()); Console.ReadLine(); break; case 2: var observable = new TemperatureMonitor(); var observer = new TemperatureReporter(); observer.Subscribe(observable); observable.GetTemperature(); break; case 3: var editor = new Editor(); var history = new Momento.History(); editor.SetContent("a"); history.Push(editor.CreateState()); editor.SetContent("b"); history.Push(editor.CreateState()); editor.SetContent("c"); history.Push(editor.CreateState()); editor.Restore(history.Pop()); editor.Restore(history.Pop()); Console.WriteLine(editor.GetContent()); break; case 4: Canvas canvas = new Canvas(); canvas.SelectTool(new BrushTool()); canvas.MouseDown(); canvas.MouseUp(); break; case 5: BrowseHistory browseHistory = new BrowseHistory(); browseHistory.Push("www.google.com"); browseHistory.Push("www.yahoo.com"); browseHistory.Push("www.reddif.com"); browseHistory.Push("www.youtube.com"); IIterator <string> iterator = browseHistory.CreateIterator(); while (iterator.HasNext()) { var url = iterator.Current(); Console.WriteLine(url); iterator.next(); } break; case 6: //The difference between State and Strategy pattern is that in state pattern there is only a single state of the object and the behaviour is determined by the implementation injected. //In strategy pattern there could be multiple behaviours in form of multiple properties inside class such as IFilter & ICompression. The implementation injected further changes the behaviour. PhotoProcessor photoProcessor = new PhotoProcessor(new BnW(), new JPEG()); photoProcessor.ProcessPhoto(); break; case 7: //template AbstractPreFlightCheckList flightChecklist = new F16PreFlightCheckList(); flightChecklist.runChecklist(); break; case 8: //command var service = new CustomerService(); var command = new AddCustomerCommand(service); var button = new Command.Button(command); button.click(); var composite = new CompositeCommand(); composite.Add(new ResizeCommand()); composite.Add(new BlackAndWHiteCommand()); var button2 = new Command.Button(composite); button2.click(); var commandHisotry = new Command.Undo.History(); var doc = new Command.Undo.HtmlDocument(); doc.SetContent("Hello World"); var boldCommand = new BoldCommand(doc, commandHisotry); boldCommand.Execute(); Console.WriteLine(doc.GetContent()); var undoCommand = new UndoCommand(commandHisotry); undoCommand.Execute(); Console.WriteLine(doc.GetContent()); break; case 9: //Observer DataSource dataSource = new DataSource(); dataSource.AddObserver(new Chart()); dataSource.AddObserver(new SpreadSheet(dataSource)); dataSource.SetValue("value changed"); break; case 10: //Mediator //the pattern is applied to encapsulate or centralize the interactions amongst a number of objects var dialog = new ArticlesDialogBox(); dialog.SimulateUsserInteraction(); break; case 11: //Chain of Responsibility //autehnticator --> logger --> compressor --> null var compressor = new Compressor(null); var logger = new Logger(compressor); var authenticator = new Authenticator(logger); var server = new WebServer(authenticator); server.handle(new HttpRequest() { UserName = "******", Password = "******" }); break; case 12: //Visitor var document = new Visitor.HtmlDocument(); document.Add(new HeadingNode()); document.Add(new AnchorNode()); document.Execute(new HighlighOperation()); break; case 13: // Composite var shape1 = new Shape(); var shape2 = new Shape(); var group1 = new Group(); group1.Add(shape1); group1.Add(shape2); var group2 = new Group(); var shape3 = new Shape(); group2.Add(shape3); group1.Add(group2); group1.render(); break; case 14: //Adapter Image image = new Image(); ImageViewer imageViewer = new ImageViewer(image); imageViewer.Apply(new SepiaFilter()); imageViewer.Apply(new FancyAdapter(new FancyFilter())); break; case 15: //Decorator var cloudStream = new CloudStream(); var encryptData = new EncryptStream(cloudStream); var compressData = new CompressStream(encryptData); compressData.write("some random data"); break; case 16: //Facade NotificationService notificationService = new NotificationService(); notificationService.Send("Hello..", "17.0.0.1"); break; case 17: //Flyweight PointService pointService = new PointService(new PointFactory()); var points = pointService.getPoints(); foreach (var p in points) { p.draw(); } break; case 18: //Bridge AdvancedRemoteControl remote = new AdvancedRemoteControl(new SonyTv()); remote.setChannel(1); break; case 19: //Proxy Library lib = new Library(); List <string> bookNames = new List <string>() { "a", "b", "c" }; foreach (var book in bookNames) { lib.eBooks.Add(book, new EBookProxy(book)); } lib.OpenEbook("a"); break; case 20: //Factory Method FactoryMethod.Employee emp = new FactoryMethod.Employee(); BaseEmployeeFactory permanentEmp = new PermanentEmployeeFactory(emp); permanentEmp.ApplySalary(); Console.WriteLine(emp.HouseAllowance); break; case 21: //Abstract Factory AbstractFactory.Employee emp1 = new AbstractFactory.Employee(); emp1.EmployeeTypeID = 1; emp1.JobDescription = "Manager"; EmployeeSystemFactory esf = new EmployeeSystemFactory(); var computerFactory = esf.Create(emp1); Console.WriteLine($"{computerFactory.GetType()}, {computerFactory.Processor()}, {computerFactory.SystemType()}, {computerFactory.Brand()}"); break; case 22: //Builder Builder.IToyBuilder toyBuilder = new Builder.PremiumToyBuilder(); Builder.ToyDirector toyDirector = new Builder.ToyDirector(toyBuilder); toyDirector.CreateFullFledgedToy(); Console.WriteLine(toyDirector.GetToy()); break; case 23: //Fluent Builder //Difference of implementation is visible in Director class. FluentBuilder.IToyBuilder toyBuilder1 = new FluentBuilder.PremiumToyBuilder(); FluentBuilder.ToyDirector toyDirector1 = new FluentBuilder.ToyDirector(toyBuilder1); toyDirector1.CreateFullFledgedToy(); Console.WriteLine(toyDirector1.GetToy()); break; case 24: //Object Pool ObjectPool <OneExpensiveObjToCreate> objPool = new ObjectPool <OneExpensiveObjToCreate>(); OneExpensiveObjToCreate obj = objPool.Get(); objPool.Release(obj); break; } Console.ReadLine(); }