public JsonResult SearchJsonResult(string location, int currentPageIndex, string sortField,
            bool sortDirectionDesc)
        {
            try
            {
                var srch = new BasicSearch();

                srch.location = location;

                var info = new SortingPagingInfo();

                info.SortField = sortField;
                info.SortDirectionDesc = sortDirectionDesc;
                info.PageSize = 9;

                info.CurrentPageIndex = currentPageIndex;

                var y = lr.SearchListings(srch, info);

                //string json = new JavaScriptSerializer().Serialize(x);
                //JsonResult json = Json( from obj in y.listings select new { Id = obj.Id, Address = obj.Address, Price = obj.Price, PriceType = obj.PriceType, City = obj.City, CurrentPage = obj.SortInfo.CurrentPageIndex, PageCount = obj.SortInfo.PageCount, ImageGallery = from objimg in obj.ListingImageGalleries select new { ImagePath = objimg.ImagePath }}, JsonRequestBehavior.AllowGet);

                var json = Json(new
                {
                    NoRecs = y.NoResults,
                    y.PageCount,
                    Listings = from obj in y.listings
                        select
                            new
                            {
                                obj.Id,
                                //obj.Address,
                                //obj.Title,
                                //obj.Telephone,
                                //obj.Email,
                                //obj.Description,
                                //obj.DateListed,
                                //ImageGallery = from objimg in obj.ListingImageGalleries select new {objimg.ImagePath}
                            }
                }, JsonRequestBehavior.AllowGet);

                return json;
            }
            catch
            {
                return Json("", JsonRequestBehavior.AllowGet);
            }
        }
        public void SearchListings_should_only_display_distinct()
        {
            var service = new EF_ListingRepository(db);
            var srch = new BasicSearch();

            srch.location = "59.31749017230652,18.009874877929633";
            var info = new SortingPagingInfo();

            info.SortField = SiteConstants.SortFields.DateListed;
            info.SortDirectionDesc = true;
            info.PageSize = 9;

            info.CurrentPageIndex = 0;

            var listings = service.SearchListings(srch, info);

            Assert.IsNotNull(listings, "No listings returned");
            //Assert.AreEqual(3, listings.listings.Count(), "Incorrect No listings returned");
            Assert.AreNotEqual(listings.listings.ToList()[1], listings.listings.ToList()[2], "Duplicate Listing");
            Assert.AreNotEqual(listings.listings.ToList()[1].Id, listings.listings.ToList()[2].Id, "Incorrect listing returned");
        }