Update title case formatter for AutoMapper
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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" />
|
||||||
|
|||||||
Reference in New Issue
Block a user