public async Task <Guid> HandleAsync(CreateLegacyNotificationApplication message) { var notification = await notificationApplicationFactory.CreateLegacy( message.NotificationType, message.CompetentAuthority, message.Number); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public async Task CanRemoveFacilityOtherThanActualSiteOfTreatment() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); context.Facilities.Add(facilityCollection); await context.SaveChangesAsync(); var facility = facilityCollection.AddFacility(business, address, contact); var anotherFacility = facilityCollection.AddFacility(business, address, contact); await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 2); facilityCollection.SetFacilityAsSiteOfTreatment(facility.Id); await context.SaveChangesAsync(); facilityCollection.RemoveFacility(anotherFacility.Id); await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 1); }
public static ImportNotificationOverview Load(ImportNotification notification, ImportNotificationAssessment assessment, Exporter exporter, Importer importer, Producer producer, FacilityCollection facilities, Shipment shipment, TransportRoute transportRoute, WasteOperation wasteOperation, WasteType wasteType) { return new ImportNotificationOverview { Notification = notification, Assessment = assessment, Exporter = exporter, Importer = importer, Producer = producer, Facilities = facilities, Shipment = shipment, TransportRoute = transportRoute, WasteOperation = wasteOperation, WasteType = wasteType }; }
public async Task CopyAsync(IwsContext context, Guid notificationSourceId, Guid notificationDestinationId) { var originalFacilities = await context.Facilities .AsNoTracking() .Include("FacilitiesCollection") .SingleOrDefaultAsync(f => f.NotificationId == notificationSourceId); var newFacilities = new FacilityCollection(notificationDestinationId); if (originalFacilities != null) { foreach (var facility in originalFacilities.Facilities) { var newFacility = newFacilities.AddFacility(facility.Business, facility.Address, facility.Contact); if (facility.IsActualSiteOfTreatment) { typeof(Facility).GetProperty("IsActualSiteOfTreatment") .SetValue(newFacility, true, null); } } typeof(FacilityCollection).GetProperty("AllFacilitiesPreconsented") .SetValue(newFacilities, originalFacilities.AllFacilitiesPreconsented, null); } context.Facilities.Add(newFacilities); }
public async Task CanAddMultipleFacilities() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); context.Facilities.Add(facilityCollection); await context.SaveChangesAsync(); for (int i = 0; i < 5; i++) { facilityCollection.AddFacility(business, address, contact); } await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 5); }
private void AddFacilities(Guid sourceId, Guid destinationId) { var sourceFacilities = new FacilityCollection(sourceId); var destinationFacilities = new FacilityCollection(destinationId); context.Facilities.Add(sourceFacilities); context.Facilities.Add(destinationFacilities); }
private FacilityCollection GetFacilityCollection() { var facilityCollection = new FacilityCollection(notificationId); facilityCollection.AddFacility(new TestableBusiness(), new TestableAddress(), new TestableContact()); facilityCollection.AddFacility(new TestableBusiness(), new TestableAddress(), new TestableContact()); return(facilityCollection); }
public void HasMultipleFacilities_SingleFacility_IsFalse() { var newFacilityCollection = new FacilityCollection(notification.Id); newFacilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(), ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact()); Assert.False(newFacilityCollection.HasMultipleFacilities); }
public GeneralViewModel(NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection, DateTimeFormatter dateTimeFormatter, QuantityFormatter quantityFormatter, PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter) { Number = notification.NotificationNumber; IsDisposal = notification.NotificationType.Equals(NotificationType.Disposal); IsRecovery = notification.NotificationType.Equals(NotificationType.Recovery); var isPreconsented = facilityCollection.AllFacilitiesPreconsented; if (!isPreconsented.HasValue) { IsPreconsented = false; IsNotPreconsented = false; } else { IsPreconsented = isPreconsented.GetValueOrDefault(); IsNotPreconsented = !isPreconsented.GetValueOrDefault(); } if (shipmentInfo.NumberOfShipments > 1) { IsIndividualShipment = false; IsNotIndividualShipment = true; } else { IsIndividualShipment = true; IsNotIndividualShipment = false; } IntendedNumberOfShipments = shipmentInfo.NumberOfShipments.ToString(); FirstDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.FirstDate); LastDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.LastDate); SetIntendedQuantityFields(shipmentInfo, quantityFormatter); var hasSpecialHandlingRequirements = notification.HasSpecialHandlingRequirements; if (!hasSpecialHandlingRequirements.HasValue) { IsSpecialHandling = false; IsNotSpecialHandling = false; } else { IsSpecialHandling = hasSpecialHandlingRequirements.GetValueOrDefault(); IsNotSpecialHandling = !hasSpecialHandlingRequirements.GetValueOrDefault(); } PackagingTypes = GetPackagingInfo(notification); PhysicalCharacteristics = physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString( notification.PhysicalCharacteristics); }
public FacilityBlock(IList<MergeField> mergeFields, FacilityCollection facilityCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); var numberOfFacilities = facilityCollection.Facilities.Count(); data = facilityCollection.Facilities.Select(p => new FacilityViewModel(p, numberOfFacilities)).ToList(); //The facility annex contains a set of different merge fields for facility marked as Actual Site of Treatment. AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); ((List<MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, ActualSiteOfTreatment)); }
public GeneralBlock(IList<MergeField> mergeFields, NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "General"); data = new GeneralViewModel(notification, shipmentInfo, facilityCollection, new DateTimeFormatter(), new QuantityFormatter(), new PhysicalCharacteristicsFormatter()); }
public NotificationInterimTests() { var facilityRepository = A.Fake <IFacilityRepository>(); facilityCollection = new FacilityCollection(notificationId); A.CallTo(() => facilityRepository.GetByNotificationId(notificationId)) .Returns(facilityCollection); notificationInterim = new NotificationInterim(facilityRepository); }
public NotificationInterimTests() { var facilityRepository = A.Fake<IFacilityRepository>(); facilityCollection = new FacilityCollection(notificationId); A.CallTo(() => facilityRepository.GetByNotificationId(notificationId)) .Returns(facilityCollection); notificationInterim = new NotificationInterim(facilityRepository); }
private void SetupFacilityCollection(bool? isInterim) { var facilityCollection = new FacilityCollection(notificationId); if (isInterim.HasValue) { facilityCollection.SetIsInterim(isInterim.Value); } A.CallTo(() => facilityRepository.GetByNotificationId(notificationId)) .Returns(facilityCollection); }
private void SetupFacilityCollection(bool?isInterim) { var facilityCollection = new FacilityCollection(notificationId); if (isInterim.HasValue) { facilityCollection.SetIsInterim(isInterim.Value); } A.CallTo(() => facilityRepository.GetByNotificationId(notificationId)) .Returns(facilityCollection); }
public FacilityBlock(IList <MergeField> mergeFields, FacilityCollection facilityCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); var numberOfFacilities = facilityCollection.Facilities.Count(); data = facilityCollection.Facilities.Select(p => new FacilityViewModel(p, numberOfFacilities)).ToList(); //The facility annex contains a set of different merge fields for facility marked as Actual Site of Treatment. AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); ((List <MergeField>)AnnexMergeFields).AddRange(MergeFieldLocator.GetAnnexMergeFields(mergeFields, ActualSiteOfTreatment)); }
public NotificationFacilityTests() { notification = new NotificationApplication(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); facilityCollection = new FacilityCollection(notification.Id); facility1 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(), ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact()); facility2 = facilityCollection.AddFacility(ObjectFactory.CreateEmptyBusiness(), ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact()); }
private FacilityCollection GetValidFacilities(bool addedToAddressBook) { FacilityCollection result = new FacilityCollection(); result.Facilities = new System.Collections.Generic.List <Facility>() { new Facility(Guid.NewGuid()) { Address = AddressTestData.GetValidTestAddress(countryId), Contact = ContactTestData.GetValidTestContact(), BusinessName = "Test facility", IsAddedToAddressBook = addedToAddressBook } }; return(result); }
public void SiteOfTreatmentSet_HasNoValidationError() { var facilityCollection = new FacilityCollection { Facilities = new List <Facility>() { new Facility(AnyGuid) { IsActualSite = true }, new Facility(AnyGuid) { IsActualSite = false } } }; validator.ShouldNotHaveValidationErrorFor(x => x.Facilities, facilityCollection); }
public void SiteOfTreatmentSet_HasNoValidationError() { var facilityCollection = new FacilityCollection { Facilities = new List<Facility>() { new Facility(AnyGuid) { IsActualSite = true }, new Facility(AnyGuid) { IsActualSite = false } } }; validator.ShouldNotHaveValidationErrorFor(x => x.Facilities, facilityCollection); }
public async Task GetNotificationShipmentInfoByIdChecksAuthorization() { var notification = NotificationApplicationFactory.Create(userId, NotificationType.Recovery, UKCompetentAuthority.England, 20181); context.NotificationApplications.Add(notification); context.SaveChanges(); var notificationId = notification.Id; var shipmentsInfo = new ShipmentInfo(notificationId, new ShipmentPeriod(DateTime.Now, DateTime.Now.AddDays(10), true), 10, new ShipmentQuantity(1.0m, ShipmentQuantityUnits.Tonnes)); var assessment = new NotificationAssessment(notificationId); ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment); var facilityCollection = new FacilityCollection(notificationId); facilityCollection.AddFacility(ObjectFactory.CreateEmptyProducerBusiness(), ObjectFactory.CreateDefaultAddress(), ObjectFactory.CreateEmptyContact()); context.ShipmentInfos.Add(shipmentsInfo); context.NotificationAssessments.Add(assessment); context.Facilities.Add(facilityCollection); context.SaveChanges(); var repository = new ShipmentInfoRepository(context, notificationApplicationAuthorization); await repository.GetByNotificationId(notificationId); await repository.GetIntendedShipmentDataByNotificationId(notificationId); A.CallTo(() => notificationApplicationAuthorization.EnsureAccessAsync(notificationId)).MustHaveHappened(Repeated.Exactly.Times(2)); context.DeleteOnCommit(shipmentsInfo); context.DeleteOnCommit(assessment); context.DeleteOnCommit(facilityCollection); await context.SaveChangesAsync(); context.DeleteOnCommit(notification); await context.SaveChangesAsync(); }
public async Task <Guid> HandleAsync(CreateNotificationApplication command) { var authority = command.CompetentAuthority; var notification = await notificationApplicationFactory.CreateNew(command.NotificationType, authority); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public void HasMultipleFacilitiesFalseByDefault() { var newFacilityCollection = new FacilityCollection(notification.Id); Assert.False(newFacilityCollection.HasMultipleFacilities); }
public void Add(FacilityCollection facilityCollection) { context.Facilities.Add(facilityCollection); }
public static FacilityCollection GetFacilitiesWithUndefined() { // Call the service for data. SP.FacilitySvc.Facility[] facilities = _facilityClient.GetAllFacilityWithUndefined(); // Convert the service proxy object to a View Model object. FacilityCollection result = new FacilityCollection(facilities.ToViewModels()); return result; }
public MovementFacilityBlock(IList<MergeField> mergeFields, FacilityCollection facilityCollection) : base(mergeFields, facilityCollection) { properties = PropertyHelper.GetPropertiesForViewModel(typeof(FacilityViewModel)); }
private FacilityCollection GetFacilityCollection() { var facilityCollection = new FacilityCollection(notificationId); facilityCollection.AddFacility(new TestableBusiness(), new TestableAddress(), new TestableContact()); facilityCollection.AddFacility(new TestableBusiness(), new TestableAddress(), new TestableContact()); return facilityCollection; }
public MovementFacilityBlock(IList <MergeField> mergeFields, FacilityCollection facilityCollection) : base(mergeFields, facilityCollection) { properties = PropertyHelper.GetPropertiesForViewModel(typeof(FacilityViewModel)); }
public async Task CanRemoveFacilityOtherThanActualSiteOfTreatment() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); context.Facilities.Add(facilityCollection); await context.SaveChangesAsync(); var facility = facilityCollection.AddFacility(business, address, contact); var anotherFacility = facilityCollection.AddFacility(business, address, contact); await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 2); facilityCollection.SetFacilityAsSiteOfTreatment(facility.Id); await context.SaveChangesAsync(); facilityCollection.RemoveFacility(anotherFacility.Id); await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 1); context.DeleteOnCommit(facilityCollection); context.DeleteOnCommit(notification); await context.SaveChangesAsync(); }
public async Task CanAddMultipleFacilities() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Recovery, UKCompetentAuthority.England, 0); var address = ObjectFactory.CreateDefaultAddress(); var business = ObjectFactory.CreateEmptyBusiness(); var contact = ObjectFactory.CreateEmptyContact(); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); context.Facilities.Add(facilityCollection); await context.SaveChangesAsync(); for (int i = 0; i < 5; i++) { facilityCollection.AddFacility(business, address, contact); } await context.SaveChangesAsync(); Assert.True(facilityCollection.Facilities.Count() == 5); context.DeleteOnCommit(facilityCollection); context.DeleteOnCommit(notification); await context.SaveChangesAsync(); }
public void CanCreateFacilityCollection() { var facilityCollection = new FacilityCollection(importNotificationId, validFacilities, true); Assert.IsType <FacilityCollection>(facilityCollection); }
public void HasNoFacilities_HasValidationError() { var facilityCollection = new FacilityCollection(); validator.ShouldHaveValidationErrorFor(x => x.Facilities, facilityCollection); }
public GeneralViewModel(NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection, DateTimeFormatter dateTimeFormatter, QuantityFormatter quantityFormatter, PhysicalCharacteristicsFormatter physicalCharacteristicsFormatter) { Number = notification.NotificationNumber; IsDisposal = notification.NotificationType.Equals(NotificationType.Disposal); IsRecovery = notification.NotificationType.Equals(NotificationType.Recovery); var isPreconsented = facilityCollection.AllFacilitiesPreconsented; if (!isPreconsented.HasValue) { IsPreconsented = false; IsNotPreconsented = false; } else { IsPreconsented = isPreconsented.GetValueOrDefault(); IsNotPreconsented = !isPreconsented.GetValueOrDefault(); } if (shipmentInfo.NumberOfShipments > 1) { IsIndividualShipment = false; IsNotIndividualShipment = true; } else { IsIndividualShipment = true; IsNotIndividualShipment = false; } IntendedNumberOfShipments = shipmentInfo.NumberOfShipments.ToString(); FirstDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.FirstDate); LastDeparture = dateTimeFormatter.DateTimeToDocumentFormatString(shipmentInfo.ShipmentPeriod.LastDate); SetIntendedQuantityFields(shipmentInfo, quantityFormatter); var hasSpecialHandlingRequirements = notification.HasSpecialHandlingRequirements; if (!hasSpecialHandlingRequirements.HasValue) { IsSpecialHandling = false; IsNotSpecialHandling = false; } else { IsSpecialHandling = hasSpecialHandlingRequirements.GetValueOrDefault(); IsNotSpecialHandling = !hasSpecialHandlingRequirements.GetValueOrDefault(); } PackagingTypes = GetPackagingInfo(notification); PhysicalCharacteristics = physicalCharacteristicsFormatter.PhysicalCharacteristicsToCommaDelimitedString( notification.PhysicalCharacteristics); CA = CompetentAuthorityFormatter.GetCompetentAuthority(notification.CompetentAuthority); }
public static FacilityCollection GetFacilitiesForListingTypeByListingTypeGuid(Guid listingTypeGuid) { SP.FacilitySvc.Facility[] facilities = _facilityClient.GetFacilitiesForListingTypeByListingTypeGuid(listingTypeGuid); FacilityCollection result = new FacilityCollection(); foreach (SP.FacilitySvc.Facility facility in facilities) { FacilityViewModel viewModel = new FacilityViewModel(facility.FacilityGuid, facility.FacilityID, facility.FacilityName, facility.Exerpt, facility.Description, facility.Address, facility.CityStateZipGuid, facility.PhoneNumber, facility.Email, facility.Website, facility.ClientGuid, facility.ListingTypeGuid, facility.PublicPhotoFileUri); result.Add(viewModel); } return result; }
public static FacilityCollection GetFacilitiesNotForCityStateZip(Guid cityStateZipGuid) { SP.FacilitySvc.Facility[] facilities = _facilityClient.GetFacilitiesNotForCityStateZip(cityStateZipGuid); FacilityCollection result = new FacilityCollection(facilities.ToViewModels()); return result; }
public GeneralBlock(IList <MergeField> mergeFields, NotificationApplication notification, ShipmentInfo shipmentInfo, FacilityCollection facilityCollection) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, "General"); data = new GeneralViewModel(notification, shipmentInfo, facilityCollection, new DateTimeFormatter(), new QuantityFormatter(), new PhysicalCharacteristicsFormatter()); }
public static FacilityCollection GetFacilitiesNotForOffering(Guid offeringGuid) { SP.FacilitySvc.Facility[] facilities = _facilityClient.GetFacilitiesNotForOffering(offeringGuid); FacilityCollection result = new FacilityCollection(facilities.ToViewModels()); return result; }