// format the list before returning it to the table...look better in table public List <ListObjectFormatted> FormatList(List <ListObjectSorted> list) { // sort dates in order list.Sort((x, y) => DateTime.Compare(x.SoldOn, y.SoldOn)); List <ListObjectFormatted> listForm = new List <ListObjectFormatted>(); foreach (var r in list) { ListObjectFormatted obj = new ListObjectFormatted(); // format price int noDecimal = (int)r.Price; string price = noDecimal.ToString("c0", CultureInfo.CurrentCulture); obj.Price = price; // format date obj.SoldOn = r.SoldOn.ToString("dd/MM/yyyy"); // format address string add = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(r.Address.ToLower()); obj.Address = Regex.Replace(add, "(?<=,)(?!\\s)", " "); // the rest obj.Description = r.Description; obj.NotFullMP = r.NotFullMP; obj.PostCode = r.PostCode; listForm.Add(obj); } return(listForm); }
// format the list before returning it to the table...look better in table public List<ListObjectFormatted> FormatList(List<ListObjectSorted> list) { // sort dates in order list.Sort((x, y) => DateTime.Compare(x.SoldOn, y.SoldOn)); List<ListObjectFormatted> listForm = new List<ListObjectFormatted>(); foreach (var r in list) { ListObjectFormatted obj = new ListObjectFormatted(); // format price int noDecimal = (int)r.Price; string price = noDecimal.ToString("c0", CultureInfo.CurrentCulture); obj.Price = price; // format date obj.SoldOn = r.SoldOn.ToString("dd/MM/yyyy"); // format address string add=CultureInfo.CurrentCulture.TextInfo.ToTitleCase(r.Address.ToLower()); obj.Address = Regex.Replace(add, "(?<=,)(?!\\s)", " "); // the rest obj.Description = r.Description; obj.NotFullMP = r.NotFullMP; obj.PostCode = r.PostCode; listForm.Add(obj); } return listForm; }