Exemple #1
0
        /// <summary>
        /// This function will return
        ///              Sorted Houses by Distance
        ///              Sorted Houses by Rooms with min 5 rooms
        ///              Sorted Houses by Street if room info misses
        ///              Get Nearest house from sister house and with more rooms with 10 rooms and 5000000 value
        /// </summary>
        /// <param name="baseHouseList"></param>
        /// <returns></returns>
        public HouseData GetSortedHouseInfo(List <House> baseHouseList = null)
        {
            if (baseHouseList == null)
            {
                baseHouseList = GetListofHouses();
            }
            HouseData houseData = new HouseData();

            var baseCord = PopulateHouseCoordsBasedOnAddress();

            foreach (var curHouse in baseHouseList)
            {
                var eCoord = new GeoCoordinate(curHouse.coords.lat, curHouse.coords.lon);
                curHouse.distance = baseCord.GetDistanceTo(eCoord);

                HouseInfo houseInfo = curHouse.GetHouseInfo();
                houseData.SourceData.Add(houseInfo);

                PopulateSortedHouseByDistance(houseData, houseInfo);

                //Indicates we don't have full information so sort them by Street
                if (curHouse.@params == null || [email protected] <= 0 || [email protected] <= 0)
                {
                    PopulateSortedHouseByStreet(houseData, houseInfo);
                }
                else //Indicates we have full information so sort them by rooms
                {
                    PopulateSortedHouseByRooms(houseData, houseInfo);
                    PopulateNearestHouse(houseData, houseInfo);
                }
            }
            houseData.SortedHouseByDistance.Sort((curr, comp) => curr.Distance.CompareTo(comp.Distance));
            houseData.SortedHouseByRooms.Sort((curr, comp) => curr.Rooms.CompareTo(comp.Rooms));
            houseData.SortedHouseByStreet.Sort((curr, comp) => curr.Street.CompareTo(comp.Street));
            return(houseData);
        }
Exemple #2
0
 /// <summary>
 /// Add it to Sorted list
 /// </summary>
 /// <param name="houseData"></param>
 /// <param name="curHouse"></param>
 private void PopulateSortedHouseByStreet(HouseData houseData, HouseInfo curHouse)
 {
     houseData.SortedHouseByStreet.Add(curHouse);
 }
Exemple #3
0
 /// <summary>
 /// Add it to Sorted list
 /// </summary>
 /// <param name="houseData"></param>
 /// <param name="curHouse"></param>
 private void PopulateSortedHouseByDistance(HouseData houseData, HouseInfo curHouse)
 {
     houseData.SortedHouseByDistance.Add(curHouse);
 }