T_PROJECT is the class that will be retrieve data from linq to sql and ProjectOwnerDataFields is the class that will be used to show data in view. in edit mode i have to get value from model and send it back like this. is there anyway to refactor this and remove the reverse duplication on ProjectOwnerDataFields and UpdateToModel ?
public class ProjectOwnerDataFields
{
public int Id { get; set; }
public string CompanyName { get; set; }
public string ContactPerson { get; set; }
public string CountryIsoLetter { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string Fax { get; set; }
public string Location { get; set; }
public string Province { get; set; }
public string Remark { get; set; }
public string CountryFullName
{
get
{
if (String.IsNullOrEmpty(this.CountryIsoLetter) == false)
{
return new RegionInfo(this.CountryIsoLetter).EnglishName;
}
return "";
}
}
public ProjectOwnerDataFields()
{
}
public ProjectOwnerDataFields(T_PROJECT project)
{
this.Id = project.proj_owner_id ;
this.CompanyName = project.proj_owner ;
this.ContactPerson = project.proj_owner_contact ;
this.CountryIsoLetter = project.proj_owner_country ;
this.Phone = project.proj_owner_phone ;
this.Email = project.proj_owner_email ;
this.Fax = project.proj_owner_fax ;
this.Location = project.proj_owner_location ;
this.Province = project.proj_owner_province ;
this.Remark = project.proj_remark ;
}
public void UpdateToModel(T_PROJECT project)
{
project.proj_owner = this.CompanyName ;
project.proj_owner_contact = this.ContactPerson ;
project.proj_owner_country = this.CountryIsoLetter ;
project.proj_owner_phone = this.Phone ;
project.proj_owner_email = this.Email ;
project.proj_owner_fax = this.Fax ;
project.proj_owner_location = this.Location ;
project.proj_owner_province = this.Province ;
project.proj_remark = this.Remark ;
}
}