public async Task <Guid> HandleAsync(SetTechnologyEmployed command) { var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(command.NotificationId); if (technologyEmployed == null) { technologyEmployed = command.AnnexProvided ? TechnologyEmployed.CreateTechnologyEmployedWithAnnex(command.NotificationId, command.Details) : TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(command.NotificationId, command.Details, command.FurtherDetails); context.TechnologiesEmployed.Add(technologyEmployed); } else { if (command.AnnexProvided) { technologyEmployed.SetWithAnnex(command.Details); } else { technologyEmployed.SetWithFurtherDetails(command.Details, command.FurtherDetails); } } await context.SaveChangesAsync(); return(technologyEmployed.Id); }
public async Task <IDocumentBlock> Create(Guid movementId, IList <MergeField> mergeFields) { var notification = await notificationApplicationRepository.GetByMovementId(movementId); var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(notification.Id); return(new MovementOperationBlock(mergeFields, notification, technologyEmployed)); }
public async Task <AnnexRequirements> Get(Guid notificationId) { var notification = await notificationRepository.GetById(notificationId); var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(notificationId); return (new AnnexRequirements( technologyEmployed != null && technologyEmployed.AnnexProvided, notification.WasteType != null && notification.WasteType.HasAnnex, notification.IsWasteGenerationProcessAttached.GetValueOrDefault())); }
public async Task TechnologyEmployedRequired() { technologyEmployed = new TestableTechnologyEmployed { AnnexProvided = true }; A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId)) .Returns(technologyEmployed); var result = await requiredAnnexes.Get(notificationId); Assert.True(result.IsTechnologyEmployedRequired); }
public RequiredAnnexesTests() { var notificationApplicationRepository = A.Fake<INotificationApplicationRepository>(); technologyEmployedRepository = A.Fake<ITechnologyEmployedRepository>(); notification = new TestableNotificationApplication(); notification.Id = notificationId; technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details"); A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification); A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId)) .Returns(technologyEmployed); requiredAnnexes = new RequiredAnnexes(notificationApplicationRepository, technologyEmployedRepository); }
public RequiredAnnexesTests() { var notificationApplicationRepository = A.Fake <INotificationApplicationRepository>(); technologyEmployedRepository = A.Fake <ITechnologyEmployedRepository>(); notification = new TestableNotificationApplication(); notification.Id = notificationId; technologyEmployed = TechnologyEmployed.CreateTechnologyEmployedWithFurtherDetails(notificationId, "details", "further details"); A.CallTo(() => notificationApplicationRepository.GetById(notificationId)).Returns(notification); A.CallTo(() => technologyEmployedRepository.GetByNotificaitonId(notificationId)) .Returns(technologyEmployed); requiredAnnexes = new RequiredAnnexes(notificationApplicationRepository, technologyEmployedRepository); }
public RecoveryOperation Map(NotificationApplication notification) { var technologyEmployed = Task.Run(() => technologyEmployedRepository.GetByNotificaitonId(notification.Id)).Result; return(new RecoveryOperation { NotificationId = notification.Id, NotificationType = notification.NotificationType == NotificationType.Disposal ? NotificationType.Disposal : NotificationType.Recovery, PreconstedAnswer = preconsentedAnswerMap.Map(notification), TechnologyEmployed = technologyEmployedMap.Map(technologyEmployed), ReasonForExport = notification.ReasonForExport ?? string.Empty, OperationCodes = GetOperationCodes(notification) }); }
public async Task <TechnologyEmployedData> HandleAsync(GetTechnologyEmployed message) { var technologyEmployed = await technologyEmployedRepository.GetByNotificaitonId(message.NotificationId); return(mapper.Map(technologyEmployed)); }