public ActionResult Start(GroupInfoModel gim, ShoppingCart cart, BrowseHistory bh)
        {
            string approxtime = string.Empty;
            string mysAddress = gim.Address + " " + gim.ZipCode;

            string[] s = base.GetAddressCityState(gim.Address);
            ViewBag.ValidateAddress = string.Empty;
            List <BizInfo> lb = new List <BizInfo>();

            if (string.IsNullOrEmpty(gim.Address) || string.IsNullOrEmpty(gim.ZipCode) || gim.ZipCode.Length != 5 || string.IsNullOrEmpty(s[0]) || string.IsNullOrEmpty(s[1]) || string.IsNullOrEmpty(s[2]))
            {
                ViewBag.ValidateAddress = "Oops, feel like something wrong with you address. Please check it and try again.";
            }
            else
            {
                bh.Address          = s[0];
                bh.City             = s[1];
                bh.State            = s[2];
                bh.Zip              = gim.ZipCode;
                bh.AddressCityState = s[0] + ", " + s[1] + ", " + s[2];
                List <BizInfo> lbi = BizInfoRepository.GetBizInfoByZip(gim.ZipCode, true);
                foreach (var b in lbi)
                {
                    decimal st = SearchFilter.GetDistance(mysAddress, b.BizAddressString, out approxtime);
                    if (st >= 0 && st <= b.DeliveryRadius && b.Delivery)
                    {
                        lb.Add(b);
                    }
                }
                bh.GroupBizOption = lb;
            }
            gim.LBizInfo = lb;
            gim.Cart     = cart;
            return(PartialView(gim));
        }
Example #2
0
        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));
        }