Exemplo n.º 1
0
 public PDFConverter(BindableCollection<Listing> searchResults, SearchSettingModel searchInput, object graphResults, string whatToAppend)
 {
     _searchResults = searchResults;
       _searchInput = searchInput;
       _graphResults = graphResults;
       PDFPath = GetPath();
       appendToPDF = whatToAppend;
 }
Exemplo n.º 2
0
 public PrintWindowViewModel(BindableCollection<Listing> resultsReturned, SearchSettingModel searchSettings, object graphResults, IEventAggregator eventaggregator)
 {
     _searchSettings = searchSettings;
       _resultsReturned = resultsReturned;
       _graphResults = graphResults;
       _eventAggregator = eventaggregator;
       _eventAggregator.Subscribe(this);
 }
Exemplo n.º 3
0
 public ResultScreenViewModel(BindableCollection<Listing> ReturnedSearchResults, SearchSettingModel searchSettings, IWindowManager windowManager, IEventAggregator eventaggregator)
 {
     _windowManager = windowManager;
       SearchResults = ReturnedSearchResults;
       if (SearchResults != null && SearchResults.Count < 0)
       {
     SelectedSearchResult = SearchResults[0];
       }
       _eventAggregator = eventaggregator;
       _searchSettings = searchSettings;
 }
Exemplo n.º 4
0
        public void TestCorrectDatabaseReturn()
        {
            BindableCollection<Listing> TestResults = new BindableCollection<Listing>();

              SearchSettingModel TestSearchSetting = new SearchSettingModel();

              TestSearchSetting.SearchInput = "Rendsburggade 28 9000";
              TestSearchSetting.SizeSliderLowerValue = 100;
              TestSearchSetting.SizeSliderHigherValue = 200;
              TestSearchSetting.Villa = true;
              TestSearchSetting.Lejlighed = true;
              TestSearchSetting.AreaSliderHigherValue = 3000;
              TestSearchSetting.PriceSliderHigherValue = 2500000;
              TestSearchSetting.PriceSliderLowerValue = 1000000;

              TestResults = fncy.SuperSearch(TestSearchSetting);

              foreach (var item in TestResults)
              {
            Assert.IsTrue(item.Price <= TestSearchSetting.PriceSliderHigherValue && item.Price >= TestSearchSetting.PriceSliderLowerValue);
            Assert.IsTrue(item.Size <= TestSearchSetting.SizeSliderHigherValue && item.Size >= TestSearchSetting.SizeSliderLowerValue);
            Assert.IsTrue(item.PropertyType == "Villa" || item.PropertyType == "Lejlighed");
              }
        }
Exemplo n.º 5
0
        private string SqlStringBuilderSold(SearchSettingModel input)
        {
            string sql = System.String.Format("SELECT address.IDAddress AS id, address.StreetName AS streetName, address.HouseNumber AS houseNumber, address.AreaCode AS areaCode, listings.PropertyType AS propertyType, listings.Size AS size, listings.NumberOfRooms AS numberOfRooms, listings.YearBuild AS yearBuilt, salesinfosold.SalesType AS salesType, salesinfosold.Price AS price, salesinfosold.PriceSqr AS priceSqr, salesinfosold.SalesDate AS salesDate FROM address, listings, salesinfosold WHERE address.IDAddress = listings.IDListings AND address.IDAddress = salesinfosold.IDSalesInfoSold AND ");

              string[] split = { "Unknown" };
              Listing SearchListing;
              string SearchAddress = string.Empty;
              if (input.SearchInput != null)
              {
            split = input.SearchInput.Split(' ');
            if (split.Length == 3)
            {
              SearchListing = new Listing(split[0].Trim(' '), split[1], int.Parse(split[2]));
            }
            else
            {
              for (int i = 0; i < split.Length - 3; i++)
              {
            SearchAddress += split[i] + " ";
              }
              SearchListing = new Listing(SearchAddress.Trim(' '), split[split.Length - 2], int.Parse(split[split.Length - 1]));
            }
            getCoordinates(SearchListing);

            if (input.AreaSliderLowerValue >= 0.0 && input.AreaSliderHigherValue > 0.0 && input.SameRoad == false && input.SameZipCode == false)
            {
              sql = System.String.Format("SELECT address.IDAddress AS id, address.StreetName AS streetName, address.HouseNumber AS houseNumber, address.AreaCode AS areaCode, listings.PropertyType AS propertyType, listings.Size AS size, listings.NumberOfRooms AS numberOfRooms, listings.YearBuild AS yearBuilt, salesinfosold.SalesType AS salesType, salesinfosold.Price AS price, salesinfosold.PriceSqr AS priceSqr, salesinfosold.SalesDate AS salesDate, 111.045 * DEGREES(ACOS(COS(RADIANS({0})) * COS(RADIANS(Lat)) * COS(RADIANS({1}) - RADIANS(Lng)) + SIN(RADIANS({0})) * SIN(RADIANS(Lat)))) * 1000 AS distance_in_m FROM address, listings, salesinfosold JOIN( SELECT  {0}  AS latpoint, {1} AS longpoint ) AS p ON 1 = 1 WHERE address.IDAddress = listings.IDListings AND address.IDAddress = salesinfosold.IDSalesInfoSold AND ", SearchListing.Lat, SearchListing.Lng);
            }
              }

              string sqlOr = "(";
              string AndOr = string.Empty;
              string proptype = "listings.PropertyType = ";
              List<bool> PropTypes = new List<bool> { input.Andelsbolig, input.Sommerhus, input.Lejlighed, input.Rækkehus, input.Villa, input.Andet };

              List<bool> PropTypeChecked = new List<bool>();
              foreach (var item in PropTypes)
              {
            if (item)
            {
              PropTypeChecked.Add(item);
            }
              }
              int count = PropTypeChecked.Count;

              if (input.Andelsbolig)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Andelsbolig\" " + AndOr;
            count--;
              }

              if (input.Villa)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Villa\" " + AndOr;
            count--;
              }

              if (input.Rækkehus)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Rækkehus\" " + AndOr;
            count--;
              }

              if (input.Lejlighed)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Lejlighed\" " + AndOr;
            count--;
              }
              if (input.Sommerhus)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Sommerhus\" " + AndOr;
            count--;
              }
              if (input.Andet)
              {
            AndOr = getAndOr(count);
            sqlOr += proptype + "\"Andet\" " + AndOr;
            count--;
              }

              sqlOr += ") AND ";

              if (PropTypeChecked.Count != 0)
              {
            sql += sqlOr;
              }

              if (input.PriceSliderHigherValue > 0.0)
              {
            sql += System.String.Format("salesinfosold.Price >= {0} AND salesinfosold.Price <= {1} AND ", input.PriceSliderLowerValue, input.PriceSliderHigherValue);
              }

              if (input.SizeSliderHigherValue > 0.0)
              {
            sql += System.String.Format("listings.Size >= {0} AND listings.Size <= {1} AND ", input.SizeSliderLowerValue, input.SizeSliderHigherValue);
              }

              if (input.SameRoad)
              {
            sql += System.String.Format("address.StreetName = \"{0}\" AND ", split[0].Trim(','));
              }

              if (input.SameZipCode)
              {
            sql += System.String.Format("address.AreaCode = {0} AND ", int.Parse(split[2]));
              }

              sql += System.String.Format("listings.NumberOfRooms >= {0} AND listings.NumberOfRooms <= {1} ",
              input.MinRoomCount, input.MaxRoomCount);

              if (input.AreaSliderLowerValue >= 0.0 && input.AreaSliderHigherValue > 0.0 && input.SameRoad == false && input.SameZipCode == false)
              {
            sql += System.String.Format("HAVING distance_in_m <= {0} ", input.AreaSliderHigherValue);
              }

              sql += "LIMIT 25";

              return sql;
        }
Exemplo n.º 6
0
        public BindableCollection<Listing> SuperSearch(SearchSettingModel input)
        {
            BindableCollection<Listing> Results = new BindableCollection<Listing>();
              List<Listing> listForSale = new List<Listing>();
              List<Listing> listSold = new List<Listing>();
              using (MySqlConnection connection = new MySqlConnection(connectionString))
              {
            if (input.ForSale && !input.Sold)
            {
              listForSale = connection.Query<Listing>(SqlStringBuilderForSale(input)).AsList();
            }
            else if (!input.ForSale && input.Sold)
            {
              listSold = connection.Query<Listing>(SqlStringBuilderSold(input)).AsList();
            }
            else
            {
              listSold = connection.Query<Listing>(SqlStringBuilderSold(input)).AsList();
              listForSale = connection.Query<Listing>(SqlStringBuilderForSale(input)).AsList();
            }

              }

              foreach (var ForSale in listForSale)
              {
            Results.Add(ForSale);
              }
              foreach (var Sold in listSold)
              {
            Results.Add(Sold);
              }

              return Results;
        }