private List <Snapshot_SampleAquisitionLocationCode> CastToAquisitionLocationCodes(List <string> locationCodes, int worksTrackId) { var snapshotList = new List <Snapshot_SampleAquisitionLocationCode>(); if (locationCodes != null) { foreach (var locationCode in locationCodes) { var snapshot = new Snapshot_SampleAquisitionLocationCode(); snapshot.CloneWorksTrackId = worksTrackId; snapshot.AquisitionLocationCode = locationCode; } } return(snapshotList); }
public bool DeleteSampleLocationCode(Snapshot_SampleAquisitionLocationCode composerToDelete) { using (var context = new DataContext()) { var composer = context.Snapshot_SampleAquisitionLocationCodes .Find(composerToDelete.SnapshotSampleAquisitionLocationCode); context.Snapshot_SampleAquisitionLocationCodes.Attach(composer); context.Snapshot_SampleAquisitionLocationCodes.Remove(composer); try { context.SaveChanges(); } catch (Exception) { return(false); } return(true); } }
public Snapshot_SampleAquisitionLocationCode SaveSampleAquisitionLocationCode(Snapshot_SampleAquisitionLocationCode composerSnapshot) { using (var context = new DataContext()) { context.Snapshot_SampleAquisitionLocationCodes.Add(composerSnapshot); context.SaveChanges(); return(composerSnapshot); } }