Wether I use Automapper or manual matching, which does not play any role.
All data for ReleaseViewModel must be the first in Release because it is filled with a data access layer. 90% of my model is like that. Why does overhead duplicate everything?
What about the KISS principle and add-ons?
Of course, every tool is for its respective task, but very often I read on SO that not using ViewModels in asp.net mvc is NO-GO.
Where to draw a line? Should I use ViewModels when they differ from 50%, 75% or 99% from my models?
I have a Release model:
public class Release
{
public int Id { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public DateTime CreatedAt { get; set; }
public int FailedTestsCount { get; set; }
public int SucceededTestsCount { get; set; }
public int SumTestsCount
{
get
{
return SucceededTestsCount + FailedTestsCount;
}
}
public int SumTestingTime { get; set; }
}
a viewmodel ReleaseViewModel:
public class ReleaseViewModel
{
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
[Required(ErrorMessage = "Name must not be empty.")]
[StringLength(30, ErrorMessage = "Enter max. 30 chars for a name.")]
[Remote("ReleaseExists", "Release", ErrorMessage = "This name already exists.")]
public string Name { get; set; }
public string Author { get; set; }
public DateTime CreatedAt { get; set; }
public int FailedTestsCount { get; set; }
public int SucceededTestsCount { get; set; }
public int SumTestsCount
{
get
{
return SucceededTestsCount + FailedTestsCount;
}
}
public int SumTestingTime { get; set; }
}
source
share