public async Task <NotificationApplicationOverview> GetById(Guid notificationId)
        {
            await authorization.EnsureAccessAsync(notificationId);

            var query =
                from notification in db.NotificationApplications
                where notification.Id == notificationId
                from wasteRecovery
                //left join waste recovery, if it exists
                in db.WasteRecoveries
                .Where(wr => wr.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from assessment
                //left join assessment, if it exists
                in db.NotificationAssessments
                .Where(na => na.NotificationApplicationId == notification.Id)
                .DefaultIfEmpty()
                from wasteDiposal
                in db.WasteDisposals
                .Where(wd => wd.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from exporter
                in db.Exporters
                .Where(e => e.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from importer
                in db.Importers
                .Where(i => i.NotificationId == notification.Id)
                .DefaultIfEmpty()
                from shipmentInfo
                in db.ShipmentInfos
                .Where(si => si.NotificationId == notification.Id)
                .DefaultIfEmpty()
                select new
            {
                Notification           = notification,
                WasteRecovery          = wasteRecovery,
                WasteDisposal          = wasteDiposal,
                NotificationAssessment = assessment,
                ShipmentInfo           = shipmentInfo,
                Exporter = exporter,
                Importer = importer
            };

            var data = await query.SingleAsync();

            return(NotificationApplicationOverview.Load(
                       data.Notification,
                       data.NotificationAssessment,
                       data.WasteRecovery,
                       data.WasteDisposal,
                       data.Exporter,
                       data.Importer,
                       decimal.ToInt32(await chargeCalculator.GetValue(notificationId)),
                       progressService.GetNotificationProgressInfo(notificationId)));
        }
Beispiel #2
0
 public NotificationApplicationCompletionProgress Map(NotificationApplication source)
 {
     return(progressService.GetNotificationProgressInfo(source.Id));
 }
Beispiel #3
0
 public Task <NotificationApplicationCompletionProgress> HandleAsync(GetNotificationProgressInfo message)
 {
     return(Task.FromResult(progressService.GetNotificationProgressInfo(message.NotificationId)));
 }