Exemplo n.º 1
0
        public async Task <TransportRouteData> GetTransportRoute(Guid id,
                                                                 IList <Domain.Country> countries)
        {
            var idContainer = new TransportRouteIdContainer();

            var stateOfImport = await draftRepository.GetDraftData <Draft.StateOfImport>(id);

            var stateOfExport = await draftRepository.GetDraftData <Draft.StateOfExport>(id);

            var transitStateCollection = await draftRepository.GetDraftData <Draft.TransitStateCollection>(id);

            /*
             * We must find the ids for the competent authorities and entry or exit points used by
             * the state of export, import and transit states.
             * Since these are all nullable we use a series of methods to gather the non-null ids we need
             * to load data for. This is so we can load the data in 2 calls rather than multiple calls.
             */
            AddTransitStateIds(transitStateCollection, idContainer);
            AddStateOfExportIds(stateOfExport, idContainer);
            AddStateOfImportIds(stateOfImport, idContainer);

            var competentAuthorities = await competentAuthorityRepository.GetByIds(idContainer.CompetentAuthorityIds);

            var entryOrExitPoints = await entryOrExitPointRepository.GetByIds(idContainer.EntryOfExitPointIds);

            var lookups = new TransportRouteLookups(countries, competentAuthorities, entryOrExitPoints);

            // Use the loaded competent authorities and entry or exit points to retrieve names for summary data.
            return(new TransportRouteData(GenerateTransitStates(transitStateCollection, lookups),
                                          GenerateStateOfExport(stateOfExport, lookups),
                                          GenerateStateOfImport(stateOfImport, lookups),
                                          transitStateCollection.HasNoTransitStates));
        }
Exemplo n.º 2
0
        private async Task <bool> BeWithinConsentPeriod(Shipment instance, DateTime?endDate, CancellationToken cancellationToken)
        {
            var preconsented =
                await draftImportNotificationRepository.GetDraftData <Preconsented>(instance.ImportNotificationId);

            int maxPeriodLengthMonths = preconsented.AllFacilitiesPreconsented.GetValueOrDefault() ? 36 : 12;

            if (endDate >= instance.StartDate.GetValueOrDefault().AddMonths(maxPeriodLengthMonths))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public async Task <WasteType> GetWasteType(Guid notificationId)
        {
            var wasteType = await draftRepository.GetDraftData <Draft.WasteType>(notificationId);

            var lookups = await GetWasteCodesLookup(wasteType);

            return(new WasteType
            {
                Name = wasteType.Name,
                EwcCodes = GetWasteCodeSelection(wasteType.SelectedEwcCodes, false, lookups),
                HCodes = GetWasteCodeSelection(wasteType.SelectedHCodes, wasteType.HCodeNotApplicable, lookups),
                UnClasses =
                    GetWasteCodeSelection(wasteType.SelectedUnClasses, wasteType.UnClassNotApplicable, lookups),
                YCodes = GetWasteCodeSelection(wasteType.SelectedYCodes, wasteType.YCodeNotApplicable, lookups),
                BaselCode = GetWasteCodeSelection(wasteType.SelectedBaselCode.HasValue ?
                                                  new List <Guid>
                {
                    wasteType.SelectedBaselCode.Value
                }
                    : new List <Guid>(), wasteType.BaselCodeNotListed, lookups)
            });
        }
Exemplo n.º 4
0
 public async Task <TData> HandleAsync(GetDraftData <TData> message)
 {
     return(await repository.GetDraftData <TData>(message.ImportNotificationId));
 }