public static dataModel.Contact ToDataModel(this coreModel.Contact contact, PrimaryKeyResolvingMap pkMap) { if (contact == null) { throw new ArgumentNullException("contact"); } var retVal = new dataModel.Contact(); contact.ToDataModel(retVal); if (retVal.Name == null) { retVal.Name = retVal.FullName; } pkMap.AddPair(contact, retVal); if (contact.Organizations != null) { retVal.MemberRelations = new ObservableCollection <dataModel.MemberRelation>(); foreach (var organization in contact.Organizations) { var memberRelation = new dataModel.MemberRelation { AncestorId = organization, AncestorSequence = 1, DescendantId = retVal.Id, }; retVal.MemberRelations.Add(memberRelation); } } return((dataModel.Contact)retVal); }
public coreModel.Contact Create(coreModel.Contact contact) { var entity = contact.ToDataModel(); coreModel.Contact retVal = null; using (var repository = _repositoryFactory()) { repository.Add(entity); CommitChanges(repository); } retVal = GetById(entity.Id); return(retVal); }
public coreModel.Contact Create(coreModel.Contact contact) { var entity = contact.ToDataModel(); using (var repository = _repositoryFactory()) { repository.Add(entity); CommitChanges(repository); } _dynamicPropertyService.SaveDynamicPropertyValues(contact); var retVal = GetById(entity.Id); return(retVal); }
public coreModel.Contact Create(coreModel.Contact contact) { var pkMap = new PrimaryKeyResolvingMap(); var entity = contact.ToDataModel(pkMap); using (var repository = _repositoryFactory()) { repository.Add(entity); CommitChanges(repository); pkMap.ResolvePrimaryKeys(); } _dynamicPropertyService.SaveDynamicPropertyValues(contact); var retVal = GetById(entity.Id); return(retVal); }