public async Task<ActionResult> Wishlist(int? totalWishlistItems, string WishlistItems, string WishlistSection, int? pageProperty, int? pageBidding)
        {
            ViewBag.Message = "Wishlist";
            ViewBag.CurrentItems = WishlistItems;
            ViewBag.CurrentWishlistSection = WishlistSection;

            List<string> selectedPIDItemsL = new List<string>();
            List<string> selectedBIDItemsL = new List<string>();
            string selectedPIDItems = null;
            string selectedBIDItems = null;

            if (WishlistItems == null || WishlistItems == "")
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return RedirectToAction("Index", "FrontEnd");

            string last = WishlistItems.Split(new[] { ',' }).Last();
            foreach (var item in WishlistItems.Split(new[] { ',' }))
            {
                var type = (item.Substring(0, 2).Equals("11"))? "PID":"BID";
                if (type.Equals("PID"))
                {
                    var PID = item.Substring(2);
                    selectedPIDItemsL.Add(PID);
                }
                else
                {
                    var BID = item.Substring(2);
                    selectedBIDItemsL.Add(BID);
                }
            }

            string lastP = (selectedPIDItemsL.Count != 0) ? selectedPIDItemsL.Last() : null;
            foreach (var itemP in selectedPIDItemsL)
            {
                if (itemP.Equals(lastP))
                {
                    selectedPIDItems += "ID = " + itemP;
                }
                else
                {
                    selectedPIDItems += "ID = " + itemP + " OR ";
                }
            }

            string lastB = (selectedBIDItemsL.Count != 0) ? selectedBIDItemsL.Last() : null;
            foreach (var itemB in selectedBIDItemsL)
            {
                if (itemB.Equals(lastB))
                {
                    selectedBIDItems += "ID = " + itemB;
                }
                else
                {
                    selectedBIDItems += "ID = " + itemB + " OR ";
                }
            }

            SearchBiddingsPropertyPhViewModel viewModel = new SearchBiddingsPropertyPhViewModel();

            IEnumerable<Property> allProperties = null;
            IEnumerable<Bidding> allBiddings = null;
            if (!String.IsNullOrEmpty(selectedPIDItems))
            {
                allProperties = await db.Properties.SqlQuery("SELECT * FROM Property WHERE " + selectedPIDItems).ToListAsync();
                List<HomePropertyPhotoViewModel> allPropertyPhoto = new List<HomePropertyPhotoViewModel>();
                foreach (var property in allProperties)
                {
                    HomePropertyPhotoViewModel model = new HomePropertyPhotoViewModel();
                    model.Property = property;
                    model.Photo = await db.Photos.Where(ph => ph.PropertyId == property.Id).OrderBy(ph => ph.Id).Take(1).SingleOrDefaultAsync();
                    //model.Products = db.Photos.Where(ph => ph.PropertyID == property.ID).ToList();
                    allPropertyPhoto.Add(model);
                }

                int pageSize = 9;
                int pageNumber = (pageProperty ?? 1);
                viewModel.PropertyPhotoPaged = allPropertyPhoto.ToPagedList(pageNumber, pageSize);

            }
            if (!String.IsNullOrEmpty(selectedBIDItems))
            {
                allBiddings = await db.Biddings.SqlQuery("SELECT * FROM Bidding WHERE " + selectedBIDItems).ToListAsync();

                List<BiddingsPhotoViewModel> allBiddingPhoto = new List<BiddingsPhotoViewModel>();
                foreach (var bidding in allBiddings)
                {
                    BiddingsPhotoViewModel model = new BiddingsPhotoViewModel();
                    model.Bidding = bidding;
                    model.Property = bidding.Property;
                    model.Photo = await db.Photos.Where(ph => ph.PropertyId == model.Property.Id).OrderBy(ph => ph.Id).Take(1).SingleOrDefaultAsync();
                    //model.Products = db.Photos.Where(ph => ph.PropertyID == property.ID).ToList();
                    allBiddingPhoto.Add(model);
                }

                int pageSize = 9;
                int pageNumber = (pageBidding ?? 1);
                viewModel.BiddingsPhotoPaged = allBiddingPhoto.ToPagedList(pageNumber, pageSize);
            }

            return View(viewModel);
        }
        public async Task<ActionResult> Search(string filterSearch, string currentFilter, string Sr, string propertyView, int? page)
        {
            ViewBag.CurrentSearch = filterSearch;
            ViewBag.CurrentView = propertyView;

            // Biddings Pagination
            if (Sr != null)
            {
                page = 1;
            }
            else
            {
                Sr = currentFilter;
            }

            ViewBag.CurrentFilter = Sr;

            SearchBiddingsPropertyPhViewModel viewModel = new SearchBiddingsPropertyPhViewModel();

            IEnumerable<Property> allProperties = null;
            IEnumerable<Bidding> allBiddings = null;
            if ((!String.IsNullOrEmpty(Sr) && filterSearch == "Properties") || (!String.IsNullOrEmpty(Sr) && filterSearch == null))
            {
                allProperties = await db.Properties.Where(p => p.Availability.ToString().Contains("Yes")).OrderByDescending(p => p.Id).ToListAsync();
                allProperties = allProperties.Where(p => p.Id.ToString().Contains(Sr.ToUpper()) || p.Title.ToUpper().Contains(Sr.ToUpper()) || p.Agent.FullName.ToUpper().Contains(Sr.ToUpper()) );
                List<HomePropertyPhotoViewModel> allPropertyPhoto = new List<HomePropertyPhotoViewModel>();
                foreach (var property in allProperties)
                {
                    HomePropertyPhotoViewModel model = new HomePropertyPhotoViewModel();
                    model.Property = property;
                    model.Photo = await db.Photos.Where(ph => ph.PropertyId == property.Id).OrderBy(ph => ph.Id).Take(1).SingleOrDefaultAsync();
                    //model.Products = db.Photos.Where(ph => ph.PropertyID == property.ID).ToList();
                    allPropertyPhoto.Add(model);
                }

                int pageSize = 12;
                int pageNumber = (page ?? 1);
                viewModel.PropertyPhotoPaged = allPropertyPhoto.ToPagedList(pageNumber, pageSize);
            }
            else if (Sr != null && filterSearch == "Biddings" )
            {
                allBiddings = await db.Biddings.OrderByDescending(b => b.Id).ToListAsync();
                allBiddings = allBiddings.Where(b => b.Id.ToString().Contains(Sr.ToUpper()) || b.Title.ToUpper().Contains(Sr.ToUpper()) || b.Property.Agent.FullName.ToUpper().Contains(Sr.ToUpper()));

                List<BiddingsPhotoViewModel> allBiddingPhoto = new List<BiddingsPhotoViewModel>();
                foreach (var bidding in allBiddings)
                {
                    BiddingsPhotoViewModel model = new BiddingsPhotoViewModel();
                    model.Bidding = bidding;
                    model.Property = bidding.Property;
                    model.Photo = await db.Photos.Where(ph => ph.PropertyId == model.Property.Id).OrderBy(ph => ph.Id).Take(1).SingleOrDefaultAsync();
                    //model.Products = db.Photos.Where(ph => ph.PropertyID == property.ID).ToList();
                    allBiddingPhoto.Add(model);
                }

                int pageSize = 12;
                int pageNumber = (page ?? 1);
                viewModel.BiddingsPhotoPaged = allBiddingPhoto.ToPagedList(pageNumber, pageSize);
            }
            else
            {
                ViewBag.CurrentSearch = "Properties";
            }

            

            return View(viewModel);
        }