public void UpdateViewModel(object dataModel, CatfishDbContext db) { CFEntityType model = dataModel as CFEntityType; Id = model.Id; Name = model.Name; if (!string.IsNullOrEmpty(Name)) { ErrorMessage = ""; } Description = model.Description; // TargetType = model.TargetType.ToString(); foreach (var tt in model.TargetTypesList) //MR jan 15 2018 { TargetType[(int)tt] = true; } CFTypeLabelAttribute att = Attribute.GetCustomAttribute(model.GetType(), typeof(CFTypeLabelAttribute)) as CFTypeLabelAttribute; TypeLabel = att == null?model.GetType().ToString() : att.Name; //populating the available metadata sets array MetadataService srv = new MetadataService(db); var metadataSets = srv.GetMetadataSets(); AvailableMetadataSets.Clear(); AvailableMetadataSets.Add(new MetadataSetListItem(0, "")); foreach (var ms in metadataSets) { if (!string.IsNullOrEmpty(ms.Name)) { AvailableMetadataSets.Add(new MetadataSetListItem(ms.Id, ms.Name)); List <string> addList = new List <string>(); addList.Add(""); addList = addList.Concat((ms.Fields.Select(f => f.Name).ToList())).ToList(); if (!MetadataSetFields.ContainsKey(ms.Id.ToString())) { MetadataSetFields.Add(ms.Id.ToString(), addList); } } } //populating the associated metadata sets array AssociatedMetadataSets.Clear(); foreach (var ms in model.MetadataSets) { AssociatedMetadataSets.Add(new MetadataSetListItem(ms.Id, ms.Name)); } AttributeMappings.Clear(); if (model.AttributeMappings.Count > 0) { foreach (CFEntityTypeAttributeMapping map in model.AttributeMappings) { if (map.Name.Equals("Name Mapping"))// || map.Name.Equals("Description Mapping")) { map.Deletable = false; } AttributeMappings.Add(new AttributeMapping { Id = map.Id, Name = map.Name, Field = map.FieldName, MetadataSetFieldId = map.MetadataSetId, Label = map.Label, Deletable = map.Deletable }); } } else { AttributeMappings.Add(new AttributeMapping { Id = 0, Name = "Name Mapping", Deletable = false }); AttributeMappings.Add(new AttributeMapping { Id = 0, Name = "Description Mapping", Deletable = true, ErrorMessage = "" }); } }