/// <summary> /// 建構元 /// </summary> /// <param name="content"></param> public AgencyViewModel(IPublishedContent content) { if (content != null && content.ContentType.Alias == PM.Agency.ModelTypeAlias) { PM.Agency agency = new PM.Agency(content); AgencyGroupId = agency.Parent.Id; MainAgencyId = agency.Parent.Id; Agency = LocalMap(agency); Id = agency.Id; PId = agency.Parent.Id; Name = agency.Name; } }
private AgencyItem LocalMap(PM.Agency agency) { AgencyItem item = new AgencyItem(); item.AgencyAlias = agency.AgencyAlias; item.AgencyId = agency.AgencyID; item.AgencyName = agency.AgencyName; int temp = 0; int.TryParse(agency.AgencyStatus, out temp); item.AgencyStatus = temp; item.IsHQ = agency.IsHQ; item.Address = new DataType.AddressData(agency.Address); PM.Contacts c = agency.Children <PM.Contacts>().FirstOrDefault(x => x.ContentType.Alias == PM.Contacts.ModelTypeAlias); item.Contacts = LocalMapForContacts(c); PM.Principal p = agency.Children <PM.Principal>().FirstOrDefault(x => x.ContentType.Alias == PM.Principal.ModelTypeAlias); item.Principal = LocalMapForPricipal(p); item.AccreditationName = agency.AccreditationType; return(item); }