recently i've started to use viewmodels with automapper. the problem appeared immediately. for example, i have such classes:
public class Zone
{
public int ZoneId;
public string Title;
public int BannersCount;
}
public class ZoneView
{
public int ZoneId
{
get;
set;
}
public string Title;
{
get;
set;
}
[Required(ErrorMessage = "Поле Кол-во баннеров является обязательным.")]
[Display(Name = "Кол-во баннеров*")]
public int BannersCount
{
get;
set;
}
}
and i don't want to edit Title in my view. so there i show Title not in TextEditor but so:
@Model.Title
and then in my POST action ZoneView comes with empty Title:
public ActionResult Edit(ZoneView zoneView)
after this i map it to domain model:
var zone = zonesRepository.Get(zoneView.ZoneId);
Mapper.Map<ZoneView, Zone>(zoneView, zone);
and after this in zone there is empty Title. What is the best way to act in this case?