public async Task <bool> HandleAsync(CompleteDraftImportNotification message)
        {
            var draft = await draftImportNotificationRepository.Get(message.ImportNotificationId);

            var assessment =
                await importNotificationAssessmentRepository.GetByNotification(message.ImportNotificationId);

            var result = await importNotificationValidator.ValidateAsync(draft);

            if (result.IsValid && assessment.Status == ImportNotificationStatus.NotificationReceived)
            {
                var notification =
                    await importNotificationRepository.Get(message.ImportNotificationId);

                var exporter           = mapper.Map <Exporter>(draft.Exporter);
                var facilityCollection = mapper.Map <FacilityCollection>(draft.Facilities, draft.Preconsented);
                var importer           = mapper.Map <Importer>(draft.Importer);
                var producer           = mapper.Map <Producer>(draft.Producer);
                var shipment           = mapper.Map <Shipment>(draft.Shipment, draft.Preconsented);

                var transportRoute = new Domain.ImportNotification.TransportRoute(message.ImportNotificationId,
                                                                                  mapper.Map <StateOfExport>(draft.StateOfExport),
                                                                                  mapper.Map <StateOfImport>(draft.StateOfImport));

                if (!draft.TransitStates.HasNoTransitStates)
                {
                    transportRoute.SetTransitStates(
                        new TransitStateList(draft.TransitStates.TransitStates.Select(t => mapper.Map <TransitState>(t))));
                }

                var wasteOperation = mapper.Map <WasteOperation>(draft.WasteOperation, notification);
                var wasteType      = mapper.Map <Domain.ImportNotification.WasteType>(draft.WasteType, draft.ChemicalComposition.Composition);

                exporterRepository.Add(exporter);
                facilityRepository.Add(facilityCollection);
                importerRepository.Add(importer);
                producerRepository.Add(producer);
                shipmentRepository.Add(shipment);
                transportRouteRepository.Add(transportRoute);
                wasteOperationRepository.Add(wasteOperation);
                wasteTypeRepository.Add(wasteType);

                assessment.Submit();

                await context.SaveChangesAsync();
            }

            return(result.IsValid);
        }
        public async Task <Guid> HandleAsync(SetExporterForNotification message)
        {
            var country = await context.Countries.SingleAsync(c => c.Id == message.Address.CountryId);

            var address  = ValueObjectInitializer.CreateAddress(message.Address, country.Name);
            var contact  = ValueObjectInitializer.CreateContact(message.Contact);
            var business = ValueObjectInitializer.CreateBusiness(message.Business);

            var exporter = await exporterRepository.GetExporterOrDefaultByNotificationId(message.NotificationId);

            if (exporter == null)
            {
                exporter = new Exporter(message.NotificationId, address, business, contact);
                exporterRepository.Add(exporter);
            }
            else
            {
                exporter.Update(address, business, contact);
            }

            await context.SaveChangesAsync();

            return(exporter.Id);
        }