I am from java background. Started coding the REST webservices from 3 weeks. I have been reading a lot about the MVVM design pattern for the Web API's. Every blog and every stackoverflow question explain that View Model is also a model that maps the front end/ the client. But, they does not talk about mapping the Domain model with the view model.
I am trying to understand mapping a domain model with the view model. Please take time to explain in detail.
View:
Sample view looks like below
{
"userid":"nvkjnvn",
"applicationid":"kjcnasdkjcnknc",
"settingkey":"mykey",
"settingvalue":"30",
"setting label":"mylabel",
"isactive":"yes",
"updatedon":"2017-06-22"
}
Model Class:
public class Setting
{
public string settingid { get; set; }
public string settingkey { get; set; }
public string settingValue { get; set; }
public string isActive { get; set; }
public string updatedOn { get; set; }
}
public class Application
{
public string app_id { get; set; }
public string name { get; set; }
public List<Setting> settings { get; set; }
}
public class UserSetting
{
public string userid { get; set; }
public List<Application> applications { get; set; }
}
ModelView:
public class UserSettingModelView
{
public string UserID{get; set;}
public string ApplicationID{get; set;}
public string SettingKey{get; set;}
public string SettingValue{get; set;}
public string Group{get; set;}
public string SettingLabel{get; set;}
public bool IsActive{get; set;}
public Date UpdatedOn{get; set;}
}
How to map the Model View with Domain Model.