public void Save(TestPerformedExternally testPerformedExternally) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var linqMetaData = new LinqMetaData(adapter); var update = linqMetaData.TestPerformedExternally.Any(tpe => tpe.CustomerEventScreeningTestId == testPerformedExternally.CustomerEventScreeningTestId); if (update) { var entity = new TestPerformedExternallyEntity() { EntryCompleted = testPerformedExternally.EntryCompleted, ResultEntryTypeId = testPerformedExternally.ResultEntryTypeId, ModifiedBy = testPerformedExternally.CreatedBy, ModifiedDate = DateTime.Now, }; var bucket = new RelationPredicateBucket(TestPerformedExternallyFields.CustomerEventScreeningTestId == testPerformedExternally.CustomerEventScreeningTestId); adapter.UpdateEntitiesDirectly(entity, bucket); } else { var entitiy = Mapper.Map <TestPerformedExternally, TestPerformedExternallyEntity>(testPerformedExternally); adapter.SaveEntity(entitiy); } } }
public TestPerformedExternally CreateModel(TestPerformedExternally testPerformedExternally, long customerEventScreeningTestId) { if (testPerformedExternally == null) { return(null); } return(new TestPerformedExternally { CustomerEventScreeningTestId = customerEventScreeningTestId, EntryCompleted = testPerformedExternally.EntryCompleted, ResultEntryTypeId = (long)ResultEntryType.Chat, CreatedBy = testPerformedExternally.CreatedBy, CreatedDate = testPerformedExternally.CreatedDate, ModifiedBy = testPerformedExternally.ModifiedBy, ModifiedDate = testPerformedExternally.ModifiedDate }); }