public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedWasteRecovery = await context.Set<WasteRecovery>() .AsNoTracking() .SingleOrDefaultAsync(n => n.NotificationId == sourceId); if (clonedWasteRecovery != null) { typeof(WasteRecovery).GetProperty("NotificationId") .SetValue(clonedWasteRecovery, destinationId, null); typeof(Entity).GetProperty("Id").SetValue(clonedWasteRecovery, Guid.Empty, null); context.WasteRecoveries.Add(clonedWasteRecovery); } var clonedWasteDisposal = await context.Set<WasteDisposal>() .AsNoTracking() .SingleOrDefaultAsync(n => n.NotificationId == sourceId); if (clonedWasteDisposal != null) { typeof(WasteDisposal).GetProperty("NotificationId") .SetValue(clonedWasteDisposal, destinationId, null); typeof(Entity).GetProperty("Id").SetValue(clonedWasteDisposal, Guid.Empty, null); context.WasteDisposals.Add(clonedWasteDisposal); } }
public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedWasteRecovery = await context.Set <WasteRecovery>() .AsNoTracking() .SingleOrDefaultAsync(n => n.NotificationId == sourceId); if (clonedWasteRecovery != null) { typeof(WasteRecovery).GetProperty("NotificationId") .SetValue(clonedWasteRecovery, destinationId, null); typeof(Entity).GetProperty("Id").SetValue(clonedWasteRecovery, Guid.Empty, null); context.WasteRecoveries.Add(clonedWasteRecovery); } var clonedWasteDisposal = await context.Set <WasteDisposal>() .AsNoTracking() .SingleOrDefaultAsync(n => n.NotificationId == sourceId); if (clonedWasteDisposal != null) { typeof(WasteDisposal).GetProperty("NotificationId") .SetValue(clonedWasteDisposal, destinationId, null); typeof(Entity).GetProperty("Id").SetValue(clonedWasteDisposal, Guid.Empty, null); context.WasteDisposals.Add(clonedWasteDisposal); } }
/// <summary> /// Create a detached copy of the source notification. /// This excludes intended shipments intentionally. /// This does not copy child objects where there is a navigation property on that child object since /// the change tracker is detached. /// </summary> /// <param name="id">The id of the notification to copy.</param> /// <returns>A partial copy of a notification.</returns> private async Task <NotificationApplication> GetCopyOfSourceNotification(Guid id) { // We have to force eager loading by including all navigation properties. //TODO: Filter by status var clone = await context.Set <NotificationApplication>() .AsNoTracking() .Include("OperationInfosCollection") .Include("PackagingInfosCollection") .Include("WasteType.WasteCompositionCollection") .Include("WasteType.WasteAdditionalInformationCollection") .Include("PhysicalCharacteristicsCollection") .SingleAsync(n => n.Id == id); return(clone); }
public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedMeans = await context.Set<MeansOfTransport>() .AsNoTracking() .SingleOrDefaultAsync(x => x.NotificationId == sourceId); if (clonedMeans != null) { typeof(MeansOfTransport).GetProperty("NotificationId") .SetValue(clonedMeans, destinationId, null); typeof(Entity).GetProperty("Id") .SetValue(clonedMeans, Guid.Empty, null); context.MeansOfTransports.Add(clonedMeans); } }
public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedMeans = await context.Set <MeansOfTransport>() .AsNoTracking() .SingleOrDefaultAsync(x => x.NotificationId == sourceId); if (clonedMeans != null) { typeof(MeansOfTransport).GetProperty("NotificationId") .SetValue(clonedMeans, destinationId, null); typeof(Entity).GetProperty("Id") .SetValue(clonedMeans, Guid.Empty, null); context.MeansOfTransports.Add(clonedMeans); } }
public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedImporter = await context.Set <Importer>() .AsNoTracking() .SingleOrDefaultAsync(e => e.NotificationId == sourceId); if (clonedImporter != null) { typeof(Importer).GetProperty("NotificationId") .SetValue(clonedImporter, destinationId, null); typeof(Entity).GetProperty("Id") .SetValue(clonedImporter, Guid.Empty, null); context.Importers.Add(clonedImporter); } }
public async Task CopyAsync(IwsContext context, Guid sourceId, Guid destinationId) { var clonedImporter = await context.Set<Importer>() .AsNoTracking() .SingleOrDefaultAsync(e => e.NotificationId == sourceId); if (clonedImporter != null) { typeof(Importer).GetProperty("NotificationId") .SetValue(clonedImporter, destinationId, null); typeof(Entity).GetProperty("Id") .SetValue(clonedImporter, Guid.Empty, null); context.Importers.Add(clonedImporter); } }