diff --git a/Web.Tests/DAL/CityNameCleaner.cs b/Web.Tests/DAL/CityNameCleaner.cs new file mode 100644 index 0000000..fca6772 --- /dev/null +++ b/Web.Tests/DAL/CityNameCleaner.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using MileageTraker.Web.Utility; +using NUnit.Framework; + +namespace Web.Tests.DAL +{ + [TestFixture] + public class CityNameCleaner + { + [Test] + [Ignore] + public void Clean() + { + const string cityFilename = @"C:\Temp\cities.csv"; + const string unknownCityFilename = @"C:\Temp\cities_unknown.csv"; + var unknownCities = + from line in File.ReadAllLines(unknownCityFilename) + select new {CityName = line, First = (line.Split(',')).FirstOrDefault()}; + var cities = + File.ReadAllLines(cityFilename); + + var b = + from uc in unknownCities + let topMatch = ( + from c in cities + let s = Algorithms.Similarity(uc.First, c) + orderby s descending + select new { c, s }).First() + select new + { + uc.CityName, topMatch.c, topMatch.s + }; + foreach (var l in b) + { + Console.WriteLine( + "UPDATE Log SET Notes=LEFT(CASE WHEN Notes IS NULL THEN CityName ELSE Notes + ', ' + CityName END, 64)" + + ", CityName='{1}' " + + "WHERE CityName='{0}'", + l.CityName.Replace("'", "''"), l.c); + } + } + } +} diff --git a/Web.Tests/DAL/LogDocs/Logs_BadCityName.xls b/Web.Tests/DAL/LogDocs/Logs_BadCityName.xls new file mode 100644 index 0000000..ce7fcdf Binary files /dev/null and b/Web.Tests/DAL/LogDocs/Logs_BadCityName.xls differ diff --git a/Web.Tests/Web.Tests.csproj b/Web.Tests/Web.Tests.csproj index 56614f6..f8b17b8 100644 --- a/Web.Tests/Web.Tests.csproj +++ b/Web.Tests/Web.Tests.csproj @@ -92,6 +92,7 @@ + diff --git a/Web/Models/City.cs b/Web/Models/City.cs index 5f4a0da..0d35c2c 100644 --- a/Web/Models/City.cs +++ b/Web/Models/City.cs @@ -13,6 +13,7 @@ namespace MileageTraker.Web.Models [InputSize("medium")] [Required] [Remote("CityNameAvailable", "City", ErrorMessage = "City name already in use")] + [FormatHint("Use correct capitalization")] public string Name { get; set; } [Required] public string County { get; set; } diff --git a/Web/Views/City/Create.cshtml b/Web/Views/City/Create.cshtml index a0883a8..9bc771a 100644 --- a/Web/Views/City/Create.cshtml +++ b/Web/Views/City/Create.cshtml @@ -12,16 +12,7 @@
@Html.DisplayFor(m => m.County) -@*
-
- @Html.DisplayNameFor(m => m.County) -
-
- @Html.DisplayTextFor(m => m.County) -
-
*@ @Html.HiddenFor(m => m.County) - @Html.EditorFor(m => m.Name)