public void UpdateModel(Person person, ObservableCollection <PersonStewardRegion> allPersonStewardRegions)
        {
            if (PersonStewardshipAreaSimples == null)
            {
                PersonStewardshipAreaSimples = new List <PersonStewardshipAreaSimple>();
            }

            var personStewardRegionsUpdated = PersonStewardshipAreaSimples.Select(x =>
            {
                var personStewardRegion = new PersonStewardRegion(
                    x.PersonStewardshipAreaID ?? ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(), person.PersonID,
                    x.StewardshipAreaID.GetValueOrDefault()); // will never be null due to RequiredAttribute
                return(personStewardRegion);
            }).ToList();

            person.PersonStewardRegions.Merge(personStewardRegionsUpdated,
                                              allPersonStewardRegions,
                                              (x, y) => x.PersonStewardRegionID == y.PersonStewardRegionID,
                                              (x, y) =>
            {
                x.PersonID          = y.PersonID;
                x.DNRUplandRegionID = y.DNRUplandRegionID;
            });
        }
示例#2
0
 public PersonStewardshipAreaSimple(PersonStewardRegion personStewardRegion)
 {
     PersonStewardshipAreaID = personStewardRegion.PersonStewardRegionID;
     StewardshipAreaID       = personStewardRegion.DNRUplandRegionID;
 }