public async Task <InternalUserData[]> HandleAsync(GetExistingInternalUsers message)
        {
            var user = await context.InternalUsers.SingleOrDefaultAsync(u => u.UserId == userContext.UserId.ToString());

            if (user == null || user.Status != InternalUserStatus.Approved)
            {
                throw new SecurityException(
                          "A user who is not an administrator or not approved may not retrieve the existing user list. Id: " +
                          userContext.UserId);
            }

            var users = await context.InternalUsers.Where(u =>
                                                          (u.Status == InternalUserStatus.Approved || u.Status == InternalUserStatus.Inactive) &&
                                                          u.UserId != userContext.UserId.ToString() &&
                                                          u.User.EmailConfirmed &&
                                                          u.CompetentAuthority == user.CompetentAuthority)
                        .OrderBy(u => u.User.Surname)
                        .ThenBy(u => u.User.FirstName)
                        .ToArrayAsync();

            var result = new List <InternalUserData>();

            foreach (var internalUser in users)
            {
                var claims = await userManager.GetClaimsAsync(internalUser.UserId);

                result.Add(mapper.Map(internalUser, claims));
            }

            return(result.ToArray());
        }
Ejemplo n.º 2
0
        public async Task <StateOfExportWithTransportRouteData> HandleAsync(
            GetStateOfExportWithTransportRouteDataByNotificationId message)
        {
            var transportRoute = await repository.GetByNotificationId(message.Id);

            return(transportRouteMap.Map(transportRoute, message.Id));
        }
        public async Task <DataExportNotificationData[]> HandleAsync(GetExportNotificationsReport message)
        {
            var user = await internalUserRepository.GetByUserId(userContext.UserId);

            var data = await exportNotificationsRepository.Get(message.From, message.To, user.CompetentAuthority);

            return(data.Select(x => mapper.Map(x, user.CompetentAuthority)).ToArray());
        }
Ejemplo n.º 4
0
        public async Task <InternalUserData> HandleAsync(GetInternalUserByUserId message)
        {
            var user = await context.InternalUsers.SingleAsync(u => u.UserId == message.UserId);

            var claims = await userManager.GetClaimsAsync(message.UserId);

            return(mapper.Map(user, claims));
        }
Ejemplo n.º 5
0
 public WasteCodesOverviewInfo Map(NotificationApplication notification)
 {
     return(new WasteCodesOverviewInfo
     {
         NotificationId = notification.Id,
         BaselOecdCode = wasteCodesMapper.Map(notification, CodeType.Basel),
         EwcCodes = wasteCodesMapper.Map(notification, CodeType.Ewc),
         NationExportCode = wasteCodesMapper.Map(notification, CodeType.ExportCode),
         NationImportCode = wasteCodesMapper.Map(notification, CodeType.ImportCode),
         OtherCodes = wasteCodesMapper.Map(notification, CodeType.OtherCode),
         YCodes = wasteCodesMapper.Map(notification, CodeType.Y),
         HCodes = wasteCodesMapper.Map(notification, CodeType.H),
         UnClass = wasteCodesMapper.Map(notification, CodeType.Un),
         UnNumber = wasteCodesMapper.Map(notification, CodeType.UnNumber),
         CustomCodes = wasteCodesMapper.Map(notification, CodeType.CustomsCode)
     });
 }
Ejemplo n.º 6
0
        public async Task <FinancialGuaranteeData> HandleAsync(GetFinancialGuaranteeDataByNotificationApplicationId message)
        {
            var financialGuaranteeCollection = await financialGuaranteeRepository.GetByNotificationId(message.NotificationId);

            var financialGuarantee = financialGuaranteeCollection.GetFinancialGuarantee(message.FinancialGuaranteeId);

            var authority = (await notificationApplicationRepository.GetById(message.NotificationId)).CompetentAuthority;

            return(financialGuaranteeMap.Map(financialGuarantee, authority));
        }
Ejemplo n.º 7
0
        private async Task AddToProducerAddressBook(ImporterViewModel model)
        {
            if (!model.IsAddedToAddressBook)
            {
                return;
            }

            var addressRecord = addressBookMapper.Map(model, AddressRecordType.Facility);

            await mediator.SendAsync(addressRecord);
        }
Ejemplo n.º 8
0
        public async Task <ShipmentData[]> HandleAsync(GetShipmentsReport message)
        {
            var user = await internalUserRepository.GetByUserId(userContext.UserId);

            var data =
                await
                shipmentsRepository.Get(message.From, message.To, user.CompetentAuthority, message.DateType,
                                        message.TextFieldType, message.TextFieldOperatorType, message.TextSearch);

            return(data.Select(x => mapper.Map(x, user.CompetentAuthority)).ToArray());
        }
Ejemplo n.º 9
0
        public async Task <bool> HandleAsync(AddNonObligated message)
        {
            authorization.EnsureCanAccessExternalArea();

            var aatfReturn = await returnDataAccess.GetById(message.ReturnId);

            var nonObligatedWeees = mapper.Map(message, aatfReturn);

            await nonObligatedDataAccess.InsertNonObligatedWeee(message.ReturnId, nonObligatedWeees);

            return(true);
        }
Ejemplo n.º 10
0
        public async Task <bool> HandleAsync(EditNonObligated message)
        {
            authorization.EnsureCanAccessExternalArea();

            var aatfReturn = await returnDataAccess.GetById(message.ReturnId);

            var idsToAmounts = mapper.Map(message, aatfReturn);

            await nonObligatedDataAccess.UpdateNonObligatedWeeeAmounts(message.ReturnId, idsToAmounts);

            return(true);
        }
Ejemplo n.º 11
0
        public Journey Map(NotificationApplication notification)
        {
            var transportRoute = context.TransportRoutes.SingleOrDefault(p => p.NotificationId == notification.Id);

            return(new Journey
            {
                NotificationId = notification.Id,
                TransportRoute = transportRouteMap.Map(transportRoute, notification.Id),
                EntryCustomsOffice = customsOfficeEntryMap.Map(transportRoute),
                ExitCustomsOffice = customsOfficeExitMap.Map(transportRoute)
            });
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Index(Guid id, FinancialGuaranteeDecisionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var request = requestMap.Map(model, id);

            await mediator.SendAsync(request);

            return(RedirectToAction("Index", "KeyDates"));
        }
        public async Task <FinancialGuaranteeData> HandleAsync(GetCurrentFinancialGuaranteeDetails message)
        {
            var financialGuaranteeCollection = await financialGuaranteeRepository.GetByNotificationId(message.NotificationId);

            var financialGuarantee = financialGuaranteeCollection.GetLatestFinancialGuarantee();
            var authority          = (await notificationApplicationRepository.GetById(message.NotificationId)).CompetentAuthority;
            var notificationStatus = await assessmentRepository.GetStatusByNotificationId(message.NotificationId);

            var result = financialGuaranteeMap.Map(financialGuarantee, authority);

            result.IsNotificationStatusRecordable = IsRecordableStatus(notificationStatus);

            return(result);
        }
        public async Task <FinancialGuaranteeData[]> HandleAsync(GetFinancialGuaranteeHistory message)
        {
            var financialGuaranteeCollection = await financialGuaranteeRepository.GetByNotificationId(message.NotificationId);

            var authority = (await notificationApplicationRepository.GetById(message.NotificationId)).CompetentAuthority;

            var latestFinancialGuarantee   = financialGuaranteeCollection.GetLatestFinancialGuarantee();
            var latestFinancialGuaranteeId = latestFinancialGuarantee == null ? Guid.Empty : latestFinancialGuarantee.Id;

            return(financialGuaranteeCollection.FinancialGuarantees
                   .Where(fg => fg.Id != latestFinancialGuaranteeId)
                   .OrderByDescending(fg => fg.CreatedDate)
                   .Select(fg => financialGuaranteeMap.Map(fg, authority))
                   .ToArray());
        }
Ejemplo n.º 15
0
        public async Task <WhatToDoNextPaymentData> HandleAsync(GetWhatToDoNextPaymentDataForNotification message)
        {
            var notification = await context.GetNotificationApplication(message.Id);

            var competentAuthority = await context.UnitedKingdomCompetentAuthorities.SingleAsync(
                n => n.Id == (int)notification.CompetentAuthority);

            var result = map.Map(notification, competentAuthority);

            result.Status = await assessmentRepository.GetStatusByNotificationId(message.Id);

            result.Charge = await chargeCalculator.GetValue(message.Id);

            result.AmountPaid = await transactionCalculator.TotalPaid(message.Id);

            return(result);
        }
Ejemplo n.º 16
0
        public async Task <WasteCodeData[]> HandleAsync(GetWasteCodesForNotification message)
        {
            var notification = await context.GetNotificationApplication(message.NotificationId);

            return(mapper.Map(notification, message.CodeType));
        }