Using MVC5, what is the best practice for transforming a model property into a view?
For example, I have a;
class Person
{
DateTime DateOfBirth { get; set; }
}
And I'd like to display this property as Age
(i.e; determine number of years between now and DateOfBirth
). I could just put an extra property on the Person
type, but wondering if there's a better way to consolidate this code into a single function I can invoke from multiple views as necessary?