public void Update(FamousPersonInfo famousePersonInfo) { famousPersonRepository.Update(FamousPersonConverter.ConvertToDo(famousePersonInfo), p => p.FamousPersonId); personTypeRelationRepository.DeleteByLinq(p => p.FamousPersonId == famousePersonInfo.FamousPersonId); var typeIds = famousePersonInfo.PersonTypeIds; foreach (var typeId in typeIds) { personTypeRelationRepository.Save(new PersonTypeRelation() { FamousPersonTypeId = typeId, FamousPersonId = famousePersonInfo.FamousPersonId }); } }
public FamousPersonInfo Save(FamousPersonInfo famousePersonInfo) { var person = famousPersonRepository.Save(FamousPersonConverter.ConvertToDo(famousePersonInfo)); var typeIds = famousePersonInfo.PersonTypeIds; foreach (var typeId in typeIds) { personTypeRelationRepository.Save(new PersonTypeRelation() { FamousPersonTypeId = typeId, FamousPersonId = person.FamousPersonId }); } famousePersonInfo.FamousPersonId = person.FamousPersonId; return(famousePersonInfo); }