public static Aatf CreateAatf(DatabaseWrapper database, Organisation organisation, short year = 2019, bool hasLocalArea = true, bool hasPanArea = true, string name = null) { LocalArea localArea = null; if (hasLocalArea) { localArea = database.WeeeContext.LocalAreas.First(); } PanArea panArea = null; if (hasPanArea) { panArea = database.WeeeContext.PanAreas.First(); } var aatfName = "aatfname"; if (!string.IsNullOrWhiteSpace(name)) { aatfName = name; } return(new Aatf(aatfName, database.WeeeContext.UKCompetentAuthorities.First(), "number", AatfStatus.Approved, organisation, CreateAatfAddress(database), AatfSize.Large, DateTime.Now, CreateDefaultContact(database.WeeeContext.Countries.First()), FacilityType.Aatf, year, localArea, panArea)); }
public void Map_GivenSource_PanAreaDataMustBeMapped() { var panArea = new PanArea() { Name = "PName", CompetentAuthorityId = Guid.NewGuid(), Id = Guid.NewGuid() }; var result = mapper.Map(panArea); result.Name.Should().Be(panArea.Name); result.Id.Should().Be(panArea.Id); result.CompetentAuthorityId.Should().Be(panArea.CompetentAuthorityId); }
public async Task <bool> HandleAsync(AddAatf message) { authorization.EnsureCanAccessInternalArea(); authorization.EnsureUserInRole(Roles.InternalAdmin); var siteAddress = addressMapper.Map(message.Aatf.SiteAddress); var organisation = await dataAccess.GetById <Organisation>(message.OrganisationId); var competentAuthority = await commonDataAccess.FetchCompetentAuthority(message.Aatf.CompetentAuthority.Abbreviation); var contact = contactMapper.Map(message.AatfContact); LocalArea localArea = null; PanArea panArea = null; if (message.Aatf.LocalAreaData != null) { localArea = await commonDataAccess.FetchLookup <LocalArea>(message.Aatf.LocalAreaData.Id); } if (message.Aatf.PanAreaData != null) { panArea = await commonDataAccess.FetchLookup <PanArea>(message.Aatf.PanAreaData.Id); } var aatf = new Domain.AatfReturn.Aatf( message.Aatf.Name, competentAuthority, message.Aatf.ApprovalNumber, Enumeration.FromValue <Domain.AatfReturn.AatfStatus>(message.Aatf.AatfStatus.Value), organisation, siteAddress, Enumeration.FromValue <Domain.AatfReturn.AatfSize>(message.Aatf.Size.Value), message.Aatf.ApprovalDate.GetValueOrDefault(), contact, message.Aatf.FacilityType.ToDomainEnumeration <Domain.AatfReturn.FacilityType>(), message.Aatf.ComplianceYear, localArea, panArea, message.AatfId); await dataAccess.Add <Domain.AatfReturn.Aatf>(aatf); return(true); }
public async Task HandleAsync_GivenAatfAeMandatoryParametersAndPanArea_FileNameShouldBeCorrect() { GetAatfAeDetailsCsv request = new GetAatfAeDetailsCsv(fixture.Create <int>(), fixture.Create <ReportFacilityType>(), null, fixture.Create <Guid>(), null, false); PanArea panArea = fixture.Create <PanArea>(); A.CallTo(() => commonDataAccess.FetchLookup <PanArea>(request.PanArea.Value)).Returns(panArea); DateTime date = new DateTime(2019, 05, 18, 11, 12, 0); SystemTime.Freeze(date); CSVFileData data = await handler.HandleAsync(request); data.FileName.Should().Be($"{request.ComplianceYear}_{panArea.Name}_{request.FacilityType.ToString().ToUpper()}_AATF-AE-PCS-organisation details_{date:ddMMyyyy_HHmm}.csv"); SystemTime.Unfreeze(); }
public void Aatf_GivenNullPanArea_PanAreaIsNull() { var competentAuthority = A.Fake <UKCompetentAuthority>(); var organisation = A.Fake <Organisation>(); const string name = "name"; const string approvalNumber = "approvalNumber"; var aatfStatus = AatfStatus.Approved; var contact = A.Fake <AatfContact>(); var complianceYear = (Int16)2019; var localArea = A.Fake <LocalArea>(); PanArea panArea = null; var facilityType = FacilityType.Aatf; var date = DateTime.Now; var address = A.Fake <AatfAddress>(); var size = AatfSize.Large; var aatf = new Aatf(name, competentAuthority, approvalNumber, aatfStatus, organisation, address, size, date, contact, facilityType, complianceYear, localArea, panArea); aatf.PanArea.Should().Be(panArea); }
public virtual void UpdateDetails(string name, UKCompetentAuthority competentAuthority, string approvalNumber, AatfStatus aatfStatus, Organisation organisation, AatfSize aatfSize, DateTime?approvalDate, LocalArea localArea, PanArea panArea) { Name = name; CompetentAuthority = competentAuthority; ApprovalNumber = approvalNumber; AatfStatus = aatfStatus; Organisation = organisation; Size = aatfSize; ApprovalDate = approvalDate; LocalArea = localArea; if (localArea == null) { LocalAreaId = null; } PanArea = panArea; if (panArea == null) { PanAreaId = null; } }
public Aatf(string name, UKCompetentAuthority competentAuthority, string approvalNumber, AatfStatus aatfStatus, Organisation organisation, AatfAddress aatfSiteAddress, AatfSize aatfSize, DateTime approvalDate, AatfContact contact, FacilityType facilityType, Int16 complianceYear, LocalArea localArea, PanArea panArea, Guid?aatfId = null) { Guard.ArgumentNotNullOrEmpty(() => name, name); Guard.ArgumentNotNullOrEmpty(() => approvalNumber, approvalNumber); Guard.ArgumentNotNull(() => competentAuthority, competentAuthority); Guard.ArgumentNotNull(() => aatfStatus, aatfStatus); Guard.ArgumentNotNull(() => organisation, organisation); Guard.ArgumentNotNull(() => contact, contact); Guard.ArgumentNotNull(() => aatfSize, aatfSize); Guard.ArgumentNotNull(() => aatfSiteAddress, aatfSiteAddress); Guard.ArgumentNotNull(() => facilityType, facilityType); Name = name; CompetentAuthority = competentAuthority; ApprovalNumber = approvalNumber; AatfStatus = aatfStatus; Organisation = organisation; Size = aatfSize; SiteAddress = aatfSiteAddress; ApprovalDate = approvalDate; Contact = contact; FacilityType = facilityType; ComplianceYear = complianceYear; LocalArea = localArea; PanArea = panArea; AatfId = aatfId == null?Guid.NewGuid() : aatfId.Value; }
public async Task HandleAsync_GivenMandatoryParametersAndAllOptionalParameters_FileNameShouldBeCorrect() { UKCompetentAuthority ca = fixture.Create <UKCompetentAuthority>(); LocalArea localArea = fixture.Create <LocalArea>(); PanArea panArea = fixture.Create <PanArea>(); GetAatfAeDetailsCsv request = new GetAatfAeDetailsCsv(fixture.Create <int>(), fixture.Create <ReportFacilityType>(), ca.Id, panArea.Id, localArea.Id, false); A.CallTo(() => commonDataAccess.FetchCompetentAuthorityById(request.AuthorityId.Value)).Returns(ca); A.CallTo(() => commonDataAccess.FetchLookup <LocalArea>(request.LocalArea.Value)).Returns(localArea); A.CallTo(() => commonDataAccess.FetchLookup <PanArea>(request.PanArea.Value)).Returns(panArea); DateTime date = new DateTime(2019, 05, 18, 11, 12, 0); SystemTime.Freeze(date); CSVFileData data = await handler.HandleAsync(request); data.FileName.Should().Be($"{request.ComplianceYear}_{ca.Abbreviation}_{panArea.Name}_{request.FacilityType.ToString().ToUpper()}_AATF-AE-PCS-organisation details_{date:ddMMyyyy_HHmm}.csv"); SystemTime.Unfreeze(); }
void OnManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e) { _panAreaTransform = PanArea.GetCompositeTransform(); _paneRootTransform = PaneRoot.GetCompositeTransform(); }
private void buttonRecenterMainCanvas_Click(object sender, RoutedEventArgs e) { PanArea.Reset(); }