public async Task <ActionResult> LandingSelectShop(int shopType, string address, string addressTyped, decimal latitude, decimal longitude)
        {
            var foundedshops = ShoppingService.GetNearestShop(shopType, latitude, longitude, address);
            var bestshop     = foundedshops.FirstOrDefault();

            Session["address"]   = address;
            Session["latitude"]  = latitude;
            Session["longitude"] = longitude;
            var    sht  = LS.Get <ShopType>();
            string type = sht.Where(x => x.ID == shopType).Select(x => x.Name).DefaultIfEmpty("").FirstOrDefault();

            var userActivity = new UserAddressSearchActivity();

            userActivity.Address       = address;
            userActivity.CreateOn      = DateTime.Now;
            userActivity.IP            = LS.GetUser_IP(Request);
            userActivity.RefererUrl    = Request.UrlReferrer != null ? Request.UrlReferrer.OriginalString : null;
            userActivity.PageUrl       = Request.RawUrl;
            userActivity.Latitude      = latitude;
            userActivity.Longitude     = longitude;
            userActivity.UserID        = LS.CurrentUser.ID;
            userActivity.AddressWroten = addressTyped;
            userActivity.ShopType      = type;

            var _url = "/c/noshop";

            if (bestshop != null)
            {
                _url = string.IsNullOrEmpty(bestshop.SeoUrl) ? "/Shop/Index/" + bestshop.ID : "/" + bestshop.SeoUrl;
                userActivity.ShopID   = bestshop.ID;
                userActivity.ShopName = bestshop.Name;
                if (foundedshops.Count() > 1)
                {
                    Session["OpenedFromHomePage" + bestshop.ID.ToString()] = DateTime.UtcNow;
                }
            }
            _db.UserAddressSearchActivities.Add(userActivity);
            await _db.SaveChangesAsync();

            return(Content(_url));
        }
        public ActionResult _ChangeShopPopup(int shopID)
        {
            var data     = new List <ShoppingCartOverviewModel>();
            var curdate  = DateTime.Now.Date;
            var lastdate = curdate.AddDays(7);
            var culture  = new System.Globalization.CultureInfo("he-IL");

            ViewBag.CurrentShopID = shopID;
            var curShop      = ShoppingService.GetShopByID(shopID);
            var curShopModel = new ShoppingCartOverviewModel();

            curShopModel.Items    = _shoppingCartService.GetShoppingCartItems(shopID, true);
            curShopModel.ShopID   = shopID;
            curShopModel.Shop     = curShop;
            curShopModel.Total    = curShopModel.Items.Count > 0 ? curShopModel.Items.Sum(x => x.UnitPrice) : 0;
            curShopModel.TotalStr = ShoppingService.FormatPrice(curShopModel.Total);
            curShopModel.Count    = curShopModel.Items.Count;
            //work times
            curShopModel.WorkTimes = _db.ShopWorkTimes.Where(x => x.ShopID == shopID && x.Active &&
                                                             (!x.IsSpecial || (x.Date >= curdate && x.Date <= lastdate))
                                                             ).OrderBy(x => x.IsSpecial).ThenBy(x => x.Day).ThenBy(x => x.Date)
                                     .Select(x => new ShipTimeModel()
            {
                Date        = x.Date,
                Day         = x.Day,
                TimeFromInt = x.TimeFrom,
                TimeToInt   = x.TimeTo,
                IsSpecial   = x.IsSpecial,
            })
                                     .ToList();
            foreach (var t in curShopModel.WorkTimes)
            {
                t.DayStr       = culture.DateTimeFormat.GetDayName(t.Day);
                t.TimeFromeStr = TimeSpan.FromMinutes(t.TimeFromInt).ToString("hh':'mm");
                t.TimeToStr    = TimeSpan.FromMinutes(t.TimeToInt).ToString("hh':'mm");
                t.DateStr      = t.Date.ToString("dd/MM");
            }
            data.Add(curShopModel);
            //missing products


            // find by address
            decimal longitude = 0;
            decimal latitude  = 0;

            if (LS.isLogined())
            {
                if (LS.CurrentUser.Latitude != 0)
                {
                    latitude = LS.CurrentUser.Latitude;
                }
                if (LS.CurrentUser.Longitude != 0)
                {
                    longitude = LS.CurrentUser.Longitude;
                }
            }


            //if not regognized
            if (longitude == 0)
            {
                if (Session["longitude"] != null)
                {
                    longitude = (decimal)Session["longitude"];
                }
            }
            if (latitude == 0)
            {
                if (Session["latitude"] != null)
                {
                    latitude = (decimal)Session["latitude"];
                }
            }
            string address = "";

            if (Session["address"] != null)
            {
                address = (string)Session["address"];
            }
            var shops = new List <Shop>();

            if (latitude == 0 || longitude == 0)
            {
                shops = ShoppingService.GetNearestShop(0, latitude, longitude, address, true).ToList();
            }
            else
            {
                shops = ShoppingService.GetNearestShop(0, latitude, longitude, address).ToList();
            }
            string[] ids = new string[] { };
            if (!string.IsNullOrEmpty(curShop.ShopTypeIDs))
            {
                ids = curShop.ShopTypeIDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            }
            Expression <Func <Shop, bool> > predicate = null;

            foreach (var s in ids)
            {
                if (predicate != null)
                {
                    predicate = predicate.MultiSearchOr(x => x.ShopTypeIDs != null &&
                                                        (x.ShopTypeIDs.Contains("," + s + ",") ||
                                                         x.ShopTypeIDs == s ||
                                                         x.ShopTypeIDs.StartsWith(s + ",") ||
                                                         x.ShopTypeIDs.EndsWith("," + s)
                                                        )
                                                        );
                }
                else
                {
                    predicate = x => x.ShopTypeIDs != null && (x.ShopTypeIDs.Contains("," + s + ",") ||
                                                               x.ShopTypeIDs == s ||
                                                               x.ShopTypeIDs.StartsWith(s + ",") ||
                                                               x.ShopTypeIDs.EndsWith("," + s)
                                                               );
                }
            }
            if (predicate != null)
            {
                shops = shops.Where(predicate.Compile()).ToList();
            }

            foreach (var shop in shops)
            {
                if (shop.ID != curShopModel.ShopID)
                {
                    var model = new ShoppingCartOverviewModel();
                    // model.Items = ShoppingCartService.GetShoppingCartItems(shop.ID, true);
                    model.Items  = ShoppingCartService.GetShoppingCartItemsByList(shop.ID, curShopModel.Items);
                    model.ShopID = shop.ID;
                    model.Shop   = shop;
                    var items = model.Items.Where(x => !x.IsNotAvaliable &&
                                                  !x.SelectedAttributeNotAvaliable &&
                                                  !x.IsHaveNotQuantity).ToList();
                    model.NotAvaliableItems = model.Items.Where(x => x.IsNotAvaliable ||
                                                                x.SelectedAttributeNotAvaliable ||
                                                                x.IsHaveNotQuantity).ToList();
                    model.Total    = items.Count > 0 ? items.Sum(x => x.UnitPrice) : 0;
                    model.TotalStr = ShoppingService.FormatPrice(model.Total);
                    model.Count    = model.Items.Count;
                    //work times

                    model.WorkTimes = _db.ShopWorkTimes.Where(x => x.ShopID == shopID && x.Active &&
                                                              (!x.IsSpecial || (x.Date >= curdate && x.Date <= lastdate))
                                                              ).OrderBy(x => x.IsSpecial).ThenBy(x => x.Day).ThenBy(x => x.Date)
                                      .Select(x => new ShipTimeModel()
                    {
                        Date        = x.Date,
                        Day         = x.Day,
                        TimeFromInt = x.TimeFrom,
                        TimeToInt   = x.TimeTo,
                        IsSpecial   = x.IsSpecial,
                    })
                                      .ToList();
                    foreach (var t in model.WorkTimes)
                    {
                        t.DayStr       = culture.DateTimeFormat.GetDayName(t.Day);
                        t.TimeFromeStr = TimeSpan.FromMinutes(t.TimeFromInt).ToString("hh':'mm");
                        t.TimeToStr    = TimeSpan.FromMinutes(t.TimeToInt).ToString("hh':'mm");
                        t.DateStr      = t.Date.ToString("dd/MM");
                    }

                    data.Add(model);
                }
            }

            if (!string.IsNullOrEmpty(curShop.Theme))
            {
                this.HttpContext.Items["ShopTheme"] = curShop.Theme;
            }

            return(PartialView(data));
        }