Update title case formatter for AutoMapper

This commit is contained in:
2018-09-19 10:40:34 -04:00
parent 83b3dd3d37
commit 3972f47e31
3 changed files with 2 additions and 16 deletions
-13
View File
@@ -1,13 +0,0 @@
using System.Globalization;
using AutoMapper;
namespace MileageTraker.Web.Utility
{
public class TitleCaseFormatter : ValueFormatter<string>
{
protected override string FormatValueCore(string value)
{
return value.ToTitleCase();
}
}
}
@@ -17,8 +17,8 @@ namespace MileageTraker.Web.ViewModels.CreateLog
static ConfirmCreateLogViewModel() static ConfirmCreateLogViewModel()
{ {
Mapper.CreateMap<CreateLogViewModel, ConfirmCreateLogViewModel>() Mapper.CreateMap<CreateLogViewModel, ConfirmCreateLogViewModel>()
.ForMember(c => c.CityName, opt => opt.AddFormatter(new TitleCaseFormatter())); .ForMember(c => c.CityName, opt => opt.ResolveUsing(vm => vm.CityName.ToTitleCase()));
} }
public ConfirmCreateLogViewModel(CreateLogViewModel createLogViewModel) public ConfirmCreateLogViewModel(CreateLogViewModel createLogViewModel)
-1
View File
@@ -329,7 +329,6 @@
<Compile Include="Utility\DateTimeTypeConverter.cs" /> <Compile Include="Utility\DateTimeTypeConverter.cs" />
<Compile Include="Utility\Algorithms.cs" /> <Compile Include="Utility\Algorithms.cs" />
<Compile Include="Utility\ExcelWriter.cs" /> <Compile Include="Utility\ExcelWriter.cs" />
<Compile Include="Utility\TitleCaseFormatter.cs" />
<Compile Include="ViewModels\CreateLog\ConfirmCreateLogViewModel.cs" /> <Compile Include="ViewModels\CreateLog\ConfirmCreateLogViewModel.cs" />
<Compile Include="ViewModels\CreateLog\CreateLogViewModel.cs" /> <Compile Include="ViewModels\CreateLog\CreateLogViewModel.cs" />
<Compile Include="ViewModels\Log\LogQueryViewModel.cs" /> <Compile Include="ViewModels\Log\LogQueryViewModel.cs" />