/// <summary> /// Traverse all the Child Entities of a Report or Summary and queue queue the appropriate messages for /// any cascade deletes. /// </summary> private void ProcessCascadeDeletes(IPublicSafetyAggregate aggregate, DataEntryAggregateType aggregateType, IUnitOfWork unitOfWork) { // Event if (aggregate.Event != null) { unitOfWork.PendingMessages.Add( EventMessageFactory.Deleted(IdentityId, aggregate.Event, aggregate.ModuleType, aggregateType)); } // Attachments foreach (var entity in aggregate.Attachments) { unitOfWork.PendingMessages.Add( AttachmentMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Drugs foreach (var entity in aggregate.Drugs) { unitOfWork.PendingMessages.Add( DrugMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Guns foreach (var entity in aggregate.Guns) { unitOfWork.PendingMessages.Add( GunMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Narratives foreach (var entity in aggregate.Narratives) { unitOfWork.PendingMessages.Add( NarrativeMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Offenses foreach (var entity in aggregate.Offenses) { unitOfWork.PendingMessages.Add( OffenseMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Officers foreach (var entity in aggregate.Officers) { unitOfWork.PendingMessages.Add( OfficerMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Organizations foreach (var entity in aggregate.Organizations) { unitOfWork.PendingMessages.Add( OrganizationMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // People foreach (var entity in aggregate.People) { unitOfWork.PendingMessages.Add( PersonMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Property foreach (var entity in aggregate.Property) { unitOfWork.PendingMessages.Add( PropertyMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // Vehicles foreach (var entity in aggregate.Vehicles) { unitOfWork.PendingMessages.Add( VehicleMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // FeesPayments foreach (var entity in aggregate.FeesPayments) { unitOfWork.PendingMessages.Add( FeePaymentMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType)); } // TODO: Module Specific Entities (i.e. OfficerInvolvedShooting and AlcoholDrugTest) }
/// <summary> /// Create the appropriate entity deleted message /// </summary> /// <param name="identityId">Id of the Identity responsible for the Delete Operation.</param> /// <param name="entity">The entity being deleted.</param> /// <param name="moduleType">Module Type of </param> /// <param name="aggregateType"></param> public static EntityModifiedMessage EntityDeleted <TEntity>(Guid identityId, TEntity entity, ModuleType moduleType, DataEntryAggregateType aggregateType) where TEntity : PublicSafetyEntity { if (entity == null) { Log.Error("EntityDeleted called with null entity."); } else if (entity is PublicSafetyAttachment) { return(AttachmentMessageFactory.Deleted(identityId, entity as PublicSafetyAttachment, moduleType, aggregateType)); } else if (entity is PublicSafetyDrug) { return(DrugMessageFactory.Deleted(identityId, entity as PublicSafetyDrug, moduleType, aggregateType)); } else if (entity is PublicSafetyEvent) { return(EventMessageFactory.Deleted(identityId, entity as PublicSafetyEvent, moduleType, aggregateType)); } else if (entity is PublicSafetyGun) { return(GunMessageFactory.Deleted(identityId, entity as PublicSafetyGun, moduleType, aggregateType)); } else if (entity is PublicSafetyNarrative) { return(NarrativeMessageFactory.Deleted(identityId, entity as PublicSafetyNarrative, moduleType, aggregateType)); } else if (entity is PublicSafetyOffense) { return(OffenseMessageFactory.Deleted(identityId, entity as PublicSafetyOffense, moduleType, aggregateType)); } else if (entity is PublicSafetyOfficer) { return(OfficerMessageFactory.Deleted(identityId, entity as PublicSafetyOfficer, moduleType, aggregateType)); } else if (entity is PublicSafetyOrganization) { return(OrganizationMessageFactory.Deleted(identityId, entity as PublicSafetyOrganization, moduleType, aggregateType)); } else if (entity is PublicSafetyPerson) { return(PersonMessageFactory.Deleted(identityId, entity as PublicSafetyPerson, moduleType, aggregateType)); } else if (entity is PublicSafetyProperty) { return(PropertyMessageFactory.Deleted(identityId, entity as PublicSafetyProperty, moduleType, aggregateType)); } else if (entity is PublicSafetyVehicle) { return(VehicleMessageFactory.Deleted(identityId, entity as PublicSafetyVehicle, moduleType, aggregateType)); } else if (entity is PublicSafetyFeesPayments) { return(FeePaymentMessageFactory.Deleted(identityId, entity as PublicSafetyFeesPayments, moduleType, aggregateType)); } //else if (entity is CallForServiceCaseReceived) // return CFSCaseReceivedMessageFactory.Deleted(identityId, entity as CallForServiceCaseReceived, moduleType, aggregateType); else if (entity is CallForServiceE911) { return(CFSE911MessageFactory.Deleted(identityId, entity as CallForServiceE911, moduleType, aggregateType)); } else if (entity is CallForServiceResponse) { return(CFSResponseMessageFactory.Deleted(identityId, entity as CallForServiceResponse, moduleType, aggregateType)); } else if (entity is CallForServiceVehicle) { return(CFSVehicleMessageFactory.Deleted(identityId, entity as CallForServiceVehicle, moduleType, aggregateType)); } else if (entity is IncidentOfficerInvolvedShooting) { return(OfficerInvolvedShootingMessageFactory.Deleted(identityId, entity as IncidentOfficerInvolvedShooting, moduleType, aggregateType)); } else { Log.Info("No EntityDeleted message is defined for entity type " + entity.GetType().Name); } return(null); }