Given a domain object:
class BirthdayDomain
{
public DateTime Birthday { get; set; }
public decimal BirthdayPresent { get; set; }
}
I have two options for passing this to a strongly-typed view:
1.
class BirthdayView
{
public DateTime Birthday { get; set; }
public decimal BirthdayPresent { get; set; }
}
and in the view
<%: Model.Birthday.ToString("d"); %>
<%: Model.BirthdayPresent.ToString("C2"); %>
2.
class BirthdayView
{
public string Birthday { get; set; }
public string BirthdayPresent { get; set; }
}
and in the controller (for instance)
BirthdayDomain bd = Repository.GetBirthday(.....)
BirthdayView bv = new BirthdayView()
{
Birthday = bd.Birthday.ToString("d");
BirthdayPresent = bd.BirthdayPresent.ToString("C2");
}
and in the view just output the strings.
My question is this: if I want to support the user's (browser's?) current locale settings so that dates and currencies are displayed the way theu expect, where is the best place to do this? Can it be done in either the view or the controller? What is the generally-accepted technique for handling this?