// sort the list based on the refines from the page choices public List <ListObjectSorted> SortList(List <ListObject> listIn) { List <ListObjectSorted> listOut = new List <ListObjectSorted>(); List <ListObjectSorted> temp = new List <ListObjectSorted>(); // change listin to listout foreach (var r in listIn) { ListObjectSorted newObj = new ListObjectSorted(); newObj.Address = r.Address; newObj.Description = r.Description.ToString(); // char to string if (newObj.Description.Equals("N")) // expand out string { newObj.Description = "New"; } else { newObj.Description = "Second Hand"; } newObj.NotFullMP = r.NotFullMP.ToString(); // char to string if (newObj.NotFullMP.Equals("N")) // expand out string { newObj.NotFullMP = "No"; } else { newObj.NotFullMP = "Yes"; } newObj.PostCode = r.PostCode; newObj.Price = r.Price; newObj.SoldOn = r.SoldOn; listOut.Add(newObj); } // if new property dwelling if (Dwelling.Equals("New Property")) { foreach (var r in listOut) { if (r.Description.Equals("New")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if second hand property dwelling if (Dwelling.Equals("Second Hand Property")) { foreach (var r in listOut) { if (r.Description.Equals("Second Hand")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if market price yes if (MarketPrice.Equals("Yes")) { foreach (var r in listOut) { if (r.NotFullMP.Equals("Yes")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if market price no if (MarketPrice.Equals("No")) { foreach (var r in listOut) { if (r.NotFullMP.Equals("No")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if county is dublin sort by postal code if (County.Equals("Dublin")) { if (!PostCode.Equals("All")) { string pc = ""; if (PostCode.Equals("county dublin")) { pc = PostCode; foreach (var r in listOut) { if (r.PostCode.Equals(pc)) { temp.Add(r); } } } else { pc = "dublin " + PostCode; foreach (var r in listOut) { if (r.PostCode.Equals(pc)) { temp.Add(r); } } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } } // take out any with price greater than max price foreach (var r in listOut) { if (r.Price <= PriceValue) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); // return list return(listOut); }
// sort the list based on the refines from the page choices public List<ListObjectSorted> SortList(List<ListObject> listIn) { List<ListObjectSorted> listOut = new List<ListObjectSorted>(); List<ListObjectSorted> temp = new List<ListObjectSorted>(); // change listin to listout foreach (var r in listIn) { ListObjectSorted newObj = new ListObjectSorted(); newObj.Address = r.Address; newObj.Description = r.Description.ToString(); // char to string if (newObj.Description.Equals("N")) // expand out string { newObj.Description = "New"; } else { newObj.Description = "Second Hand"; } newObj.NotFullMP = r.NotFullMP.ToString(); // char to string if (newObj.NotFullMP.Equals("N")) // expand out string { newObj.NotFullMP = "No"; } else { newObj.NotFullMP = "Yes"; } newObj.PostCode = r.PostCode; newObj.Price = r.Price; newObj.SoldOn = r.SoldOn; listOut.Add(newObj); } // if new property dwelling if (Dwelling.Equals("New Property")) { foreach(var r in listOut) { if (r.Description.Equals("New")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if second hand property dwelling if (Dwelling.Equals("Second Hand Property")) { foreach (var r in listOut) { if (r.Description.Equals("Second Hand")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if market price yes if (MarketPrice.Equals("Yes")) { foreach (var r in listOut) { if (r.NotFullMP.Equals("Yes")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if market price no if (MarketPrice.Equals("No")) { foreach (var r in listOut) { if (r.NotFullMP.Equals("No")) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } // if county is dublin sort by postal code if (County.Equals("Dublin")) { if (!PostCode.Equals("All")) { string pc = ""; if (PostCode.Equals("county dublin")) { pc = PostCode; foreach (var r in listOut) { if (r.PostCode.Equals(pc)) { temp.Add(r); } } } else { pc = "dublin " + PostCode; foreach (var r in listOut) { if (r.PostCode.Equals(pc)) { temp.Add(r); } } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); } } // take out any with price greater than max price foreach (var r in listOut) { if (r.Price<=PriceValue) { temp.Add(r); } } listOut.Clear(); listOut.AddRange(temp); temp.Clear(); // return list return listOut; }