Beispiel #1
0
        /// <summary>
        /// Get landplots in mentioned location, optionally order and set max price.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="price"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public static Dictionary <int, Landplot> GetLandplots(int location, int price = 0, string order = "")
        {
            string querystring1 = "", querystring2 = "";

            switch (order)
            {
            case "new":
                querystring1 = $"select _key, _val, PostDate, Price, LocationID, isOpen from Landplots where LocationID={location} and isOpen=true ";
                querystring2 = " order by PostDate desc;";
                break;

            case "price":
                querystring1 = $"select _key, _val, Price, LocationID, isOpen from Landplots where LocationID={location} and isOpen=true ";
                querystring2 = " order by Price;";
                break;

            case "prisqm":
                querystring1 = $"select _key, _val, Price, LandArea, (Price/LandArea) as SqmPrice, LocationID, isOpen from Landplots where LocationID={location} and isOpen=true ";
                querystring2 = " order by SqmPrice;";
                break;

            case "pop":
                querystring1 = $"select _key, _val, Price, Cnt, LocationID, isOpen from \"estateobject\".Landplots as A left join (select ObjectID, count(*) as Cnt from \"bookmark\".Bookmarks group by ObjectID) as B on A._key = B.ObjectID where LocationID={location} and isOpen=true ";
                querystring2 = " order by Cnt desc;";
                break;

            case "state":
                querystring1 = $"select _key, _val, Price, State, LocationID, isOpen from Landplots where LocationID={location} and isOpen=true ";
                querystring2 = " order by State desc;";
                break;

            default:
                querystring1 = $"select _key, _val, Price, LocationID, isOpen from Landplots where LocationID={location} and isOpen=true ";
                querystring2 = ";";
                break;
            }

            if (price > 0)
            {
                querystring1 += $" and Price<={price} ";
            }
            querystring1 += querystring2;
            Dictionary <int, Landplot> result = new Dictionary <int, Landplot>();

            foreach (var row in LandplotCache.Query(new SqlFieldsQuery(querystring1)))
            {
                result[(int)row[0]] = row[1] as Landplot;
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Simply get all estate objects
        /// </summary>
        /// <returns></returns>
        public static Dictionary <int, EstateObject> GetEstateObjects()
        {
            Dictionary <int, EstateObject> result = new Dictionary <int, EstateObject>();

            foreach (var row in ObjectCache.Query(new SqlFieldsQuery("select _key, _val from EstateObjects order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as EstateObject);
            }
            foreach (var row in HouseCache.Query(new SqlFieldsQuery("select _key, _val from Houses order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as House);
            }
            foreach (var row in FlatCache.Query(new SqlFieldsQuery("select _key, _val from Flats order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as Flat);
            }
            foreach (var row in LandplotCache.Query(new SqlFieldsQuery("select _key, _val from Landplots order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as Landplot);
            }
            return(result);
        }