public async Task OrganisationByIdHandler_HappyPath_ReturnsOrganisationFromId()
        {
            var authorization = AuthorizationBuilder.CreateUserAllowedToAccessOrganisation();

            var organisationId = Guid.NewGuid();
            var context = A.Fake<WeeeContext>();
            A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List<Organisation>
            {
                GetOrganisationWithId(organisationId)
            }));

            OrganisationData expectedReturnValue = new OrganisationData();
            Organisation mappedOrganisation = null;
            var organisationMap = A.Fake<IMap<Organisation, OrganisationData>>();
            A.CallTo(() => organisationMap.Map(A<Organisation>._))
                .Invokes((Organisation o) => mappedOrganisation = o)
                .Returns(expectedReturnValue);

            var handler = new OrganisationByIdHandler(authorization, context, organisationMap);
            var message = new GetOrganisationInfo(organisationId);

            var result = await handler.HandleAsync(message);

            Assert.NotNull(mappedOrganisation);
            Assert.Equal(organisationId, mappedOrganisation.Id);
            Assert.Same(expectedReturnValue, result);
        }
Ejemplo n.º 2
0
        public async Task OrganisationByIdHandler_HappyPath_ReturnsOrganisationFromId()
        {
            var authorization = AuthorizationBuilder.CreateUserWithAllRights();

            var expectedReturnValue = new OrganisationData();

            A.CallTo(() => map.Map(A <Organisation> ._)).Returns(expectedReturnValue);

            var message = new GetInternalOrganisation(organisationId);

            var result = await handler.HandleAsync(message);

            Assert.NotNull(expectedReturnValue);
            Assert.Same(expectedReturnValue, result);
        }
        public void Organisation_data_json_parses_to_object()
        {
            var json = "{ \"CompanyNumber\":\"12345678\",\"CharityNumber\":\"1234567\",\"ParentCompanyGuarantee\":false,\"FinancialTrackRecord\":true,\"NonLevyContract\":false,\"StartDate\":\"2019-03-27 00:00:00\",\"RemovedReason\":{\"Id\":5,\"Reason\":\"Inadequate Ofsted grade\",\"Description\":null,\"CreatedBy\":\"System\",\"CreatedAt\":\"2019-02-11 15:47:23\",\"UpdatedBy\":null,\"UpdatedAt\":null,\"Status\":\"Live\"}}";

            OrganisationData data = JsonConvert.DeserializeObject <OrganisationData>(json);

            data.Should().NotBeNull();
            data.CompanyNumber.Should().Be("12345678");
            data.CharityNumber.Should().Be("1234567");
            data.ParentCompanyGuarantee.Should().BeFalse();
            data.FinancialTrackRecord.Should().BeTrue();
            data.NonLevyContract.Should().BeFalse();
            data.StartDate.Should().Be(new DateTime(2019, 03, 27));
            data.RemovedReason.Id.Should().Be(5);
            data.SourceIsUKRLP.Should().BeNull();
        }
        public void Set_up_and_run_update()
        {
            _organisationStatusId1             = 1;
            _providerTypeId1                   = 10;
            _organisationTypeId1               = 100;
            _organisationUkprn                 = 11114433;
            _organisationId                    = Guid.NewGuid();
            _parentCompanyGuarantee            = true;
            _parentCompanyGuaranteeAfterChange = false;
            _updateOrganisationRepository      = new UpdateOrganisationRepository(_databaseService.WebConfiguration);
            _repository = new OrganisationRepository(_databaseService.WebConfiguration);
            _status1    = new OrganisationStatusModel {
                Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
            };
            OrganisationStatusHandler.InsertRecord(_status1);
            _providerType1 = new ProviderTypeModel {
                Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            ProviderTypeHandler.InsertRecord(_providerType1);
            _organisationTypeModel1 = new OrganisationTypeModel {
                Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            OrganisationTypeHandler.InsertRecord(_organisationTypeModel1);
            var organisationData = new OrganisationData {
                ParentCompanyGuarantee = _parentCompanyGuarantee
            };

            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId1,
                ProviderTypeId     = _providerTypeId1,
                StatusId           = _organisationStatusId1,
                StatusDate         = DateTime.Today.AddDays(5),
                LegalName          = "legal name",
                Id               = _organisationId,
                CreatedAt        = DateTime.Now,
                CreatedBy        = "Test",
                OrganisationData = JsonConvert.SerializeObject(organisationData)
            };
            OrganisationHandler.InsertRecord(_organisation);
            _originalParentCompanyGuarantee = _repository.GetParentCompanyGuarantee(_organisationId).Result;
            _changedBy = "SystemChange";

            _successfulUpdate          = _updateOrganisationRepository.UpdateParentCompanyGuarantee(_organisationId, _parentCompanyGuaranteeAfterChange, _changedBy).Result;
            _newParentCompanyGuarantee = _repository.GetParentCompanyGuarantee(_organisationId).Result;
        }
        public void Set_up_and_run_update()
        {
            _organisationStatusId         = 1;
            _providerTypeId               = 10;
            _organisationTypeId           = 100;
            _applicationDeterminedate     = DateTime.Today;
            _newApplicationDeterminedDate = DateTime.Today.AddDays(-1);
            _organisationUkprn            = 11114433;
            _organisationId               = Guid.NewGuid();
            _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper);
            _repository = new OrganisationRepository(_databaseService.DbConnectionHelper);
            _status     = new OrganisationStatusModel {
                Id = _organisationStatusId, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
            };
            OrganisationStatusHandler.InsertRecord(_status);
            _providerType = new ProviderTypeModel {
                Id = _providerTypeId, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            ProviderTypeHandler.InsertRecord(_providerType);
            _organisationTypeModel = new OrganisationTypeModel {
                Id = _organisationTypeId, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            OrganisationTypeHandler.InsertRecord(_organisationTypeModel);
            var organisationData = new OrganisationData {
                ApplicationDeterminedDate = _applicationDeterminedate
            };

            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId,
                ProviderTypeId     = _providerTypeId,
                StatusId           = _organisationStatusId,
                StatusDate         = DateTime.Today.AddDays(5),
                LegalName          = "legal name",
                Id               = _organisationId,
                CreatedAt        = DateTime.Now,
                CreatedBy        = "Test",
                OrganisationData = JsonConvert.SerializeObject(organisationData)
            };
            OrganisationHandler.InsertRecord(_organisation);
            _originalDeterminedDate = _repository.GetApplicationDeterminedDate(_organisationId).Result;
            _changedBy = "SystemChange";

            _successfulUpdate             = _updateOrganisationRepository.UpdateApplicationDeterminedDate(_organisationId, _newApplicationDeterminedDate.Value, _changedBy).Result;
            _newApplicationDeterminedDate = _repository.GetApplicationDeterminedDate(_organisationId).Result;
        }
        public async Task OrganisationByIdHandler_HappyPath_ReturnsOrganisationFromId()
        {
            A.CallTo(() => context.Organisations).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Organisation>
            {
                GetOrganisationWithId(organisationId)
            }));

            var expectedReturnValue = new OrganisationData();

            A.CallTo(() => map.Map(A <Organisation> ._)).Returns(expectedReturnValue);

            var message = new GetOrganisationInfo(organisationId);

            var result = await handler.HandleAsync(message);

            Assert.NotNull(expectedReturnValue);
            Assert.Same(expectedReturnValue, result);
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> EditRegisteredCompanyOrganisationDetails(EditRegisteredCompanyOrganisationDetailsViewModel model)
        {
            await SetBreadcrumb(model.SchemeId, model.AatfId, model.OrgId, model.FacilityType);

            if (!ModelState.IsValid)
            {
                using (var client = apiClient())
                {
                    model.BusinessAddress.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false));
                }
                return(View(model));
            }

            using (var client = apiClient())
            {
                var orgData = new OrganisationData
                {
                    Id = model.OrgId,
                    OrganisationType          = model.OrganisationType,
                    CompanyRegistrationNumber = model.CompaniesRegistrationNumber,
                    TradingName     = model.BusinessTradingName,
                    Name            = model.CompanyName,
                    BusinessAddress = model.BusinessAddress,
                };

                await client.SendAsync(User.GetAccessToken(), new UpdateOrganisationDetails(orgData));

                await cache.InvalidateOrganisationSearch();
            }

            if (model.SchemeId.HasValue)
            {
                return(RedirectScheme(model.SchemeId.Value));
            }

            if (model.AatfId.HasValue)
            {
                return(RedirectToAatf(model.AatfId.Value));
            }

            return(View(model));
        }
Ejemplo n.º 8
0
        public void setup_organisation_is_added()
        {
            _organisationStatusId1  = 1;
            _providerTypeId1        = 10;
            _organisationTypeId1    = 100;
            _organisationUkprn      = 11114433;
            _organisationId         = Guid.NewGuid();
            _parentCompanyGuarantee = true;
            _repository             = new OrganisationRepository(_databaseService.DbConnectionHelper);
            _status1 = new OrganisationStatusModel {
                Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
            };
            OrganisationStatusHandler.InsertRecord(_status1);
            _providerType1 = new ProviderTypeModel {
                Id = _providerTypeId1, ProviderType = "provider type 10", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            ProviderTypeHandler.InsertRecord(_providerType1);
            _organisationTypeModel1 = new OrganisationTypeModel {
                Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            OrganisationTypeHandler.InsertRecord(_organisationTypeModel1);

            var organisationData = new OrganisationData {
                ParentCompanyGuarantee = _parentCompanyGuarantee
            };

            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId1,
                ProviderTypeId     = _providerTypeId1,
                StatusId           = _organisationStatusId1,
                StatusDate         = DateTime.Today.AddDays(5),
                LegalName          = "legal name 1",
                Id               = _organisationId,
                CreatedAt        = DateTime.Now,
                CreatedBy        = "Test",
                OrganisationData = JsonConvert.SerializeObject(organisationData)
            };
            OrganisationHandler.InsertRecord(_organisation);
        }
Ejemplo n.º 9
0
        public void Map_GivenSource_OrganisationShouldBeMapped()
        {
            var source = new ReturnQuarterWindow(GetReturn(), GetQuarterWindow(),
                                                 A.Fake <List <DomainAatf> >(), A.Fake <List <NonObligatedWeee> >(),
                                                 A.Fake <List <WeeeReceivedAmount> >(), A.Fake <List <WeeeReusedAmount> >(), organisation,
                                                 A.Fake <List <WeeeSentOnAmount> >(),
                                                 A.Fake <List <ReturnScheme> >(),
                                                 A.Fake <List <ReturnReportOn> >(),
                                                 A.Dummy <DateTime>());

            var organisationData = new OrganisationData()
            {
                Name = "name", Id = Guid.NewGuid()
            };

            A.CallTo(() => organisationMapper.Map(source.Organisation)).Returns(organisationData);

            var result = map.Map(source);

            result.OrganisationData.Should().Be(organisationData);
        }
Ejemplo n.º 10
0
        public ActionResult OrganisationData(OrganisationData data, string prevBtn, string nextBtn)
        {
            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    WizardModel obj = GetWizard();
                    obj.OrgData.Vision  = obj.OrgData.Vision;
                    obj.OrgData.Mission = obj.OrgData.Mission;
                    obj.OrgData.WomensRightsIssuesId = obj.OrgData.WomensRightsIssuesId;
                    obj.OrgData.YearFormed           = obj.OrgData.YearFormed;
                    obj.OrgData.Founder               = obj.OrgData.Founder;
                    obj.OrgData.ReasonFormed          = obj.OrgData.ReasonFormed;
                    obj.OrgData.OperationalAreaId     = obj.OrgData.OperationalAreaId;
                    obj.OrgData.OperationalLocationId = obj.OrgData.OperationalLocationId;
                    obj.OrgData.Achievements          = obj.OrgData.Achievements;

                    return(View("AdministrationData"));
                }
            }
            return(View());
        }
Ejemplo n.º 11
0
        public async Task HandleAsync_GivenOrganisationHasAatfs_OrganisationHasAatfsShouldBeTrue()
        {
            var organisation = GetOrganisationWithId(organisationId);

            var expectedReturnValue = new OrganisationData();

            var aatf = A.Fake <Aatf>();

            A.CallTo(() => aatf.FacilityType).Returns(FacilityType.Aatf);
            A.CallTo(() => aatf.Organisation).Returns(organisation);
            A.CallTo(() => map.Map(A <Organisation> ._)).Returns(expectedReturnValue);
            A.CallTo(() => context.Aatfs).Returns(dbHelper.GetAsyncEnabledDbSet(new List <Aatf>()
            {
                aatf
            }));

            var message = new GetOrganisationInfo(organisationId);

            var result = await handler.HandleAsync(message);

            result.HasAatfs.Should().BeTrue();
        }
        public async void IndexGet_GivenValidViewModel_BreadcrumbShouldBeSet()
        {
            Guid             organisationId   = Guid.NewGuid();
            ReturnData       returnData       = A.Fake <ReturnData>();
            OrganisationData organisationData = A.Fake <OrganisationData>();
            const string     orgName          = "orgName";

            var quarterData   = new Quarter(2019, QuarterType.Q1);
            var quarterWindow = QuarterWindowTestHelper.GetDefaultQuarterWindow();
            var aatfInfo      = A.Fake <AatfData>();
            var aatfId        = Guid.NewGuid();

            const string reportingQuarter = "2019 Q1 Jan - Mar";
            const string reportingPeriod  = "Test (WEE/QW1234RE/ATF)";

            returnData.Quarter       = quarterData;
            returnData.QuarterWindow = quarterWindow;
            const string aatfName = "Test";

            aatfInfo.ApprovalNumber = "WEE/QW1234RE/ATF";

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetReturn> ._)).Returns(returnData);
            A.CallTo(() => organisationData.Id).Returns(organisationId);
            A.CallTo(() => returnData.OrganisationData).Returns(organisationData);
            A.CallTo(() => cache.FetchOrganisationName(organisationId)).Returns(orgName);

            A.CallTo(() => cache.FetchAatfData(organisationId, aatfId)).Returns(aatfInfo);
            A.CallTo(() => aatfInfo.Name).Returns(aatfName);

            await controller.Index(A.Dummy <Guid>(), A.Dummy <Guid>(), A.Dummy <Guid>(), aatfId, A.Dummy <string>());

            breadcrumb.ExternalActivity.Should().Be(BreadCrumbConstant.AatfReturn);
            breadcrumb.ExternalOrganisation.Should().Be(orgName);
            breadcrumb.OrganisationId.Should().Be(organisationId);

            Assert.Contains(reportingQuarter, breadcrumb.QuarterDisplayInfo);
            Assert.Contains(reportingPeriod, breadcrumb.AatfDisplayInfo);
        }
        public async Task GetRegisteredOfficeAddress_ApiReturnsOrganisationData_ReturnsViewWithModel()
        {
            // Arrange
            AddressData addressData = new AddressData();
            addressData.Address1 = "Address Line 1";

            OrganisationData organisationData = new OrganisationData();
            organisationData.Id = new Guid("1B7329B9-DC7F-4621-8E97-FD97CDDDBA10");
            organisationData.OrganisationType = OrganisationType.RegisteredCompany;
            organisationData.HasBusinessAddress = true;
            organisationData.BusinessAddress = addressData;

            IWeeeClient weeeClient = A.Fake<IWeeeClient>();
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetOrganisationInfo>._))
                .Returns(organisationData);

            ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>();

            OrganisationRegistrationController controller = new OrganisationRegistrationController(
                () => weeeClient,
                organisationSearcher);

            // Act
            ActionResult result = await controller.RegisteredOfficeAddress(new Guid("1B7329B9-DC7F-4621-8E97-FD97CDDDBA10"));

            // Assert
            ViewResult viewResult = result as ViewResult;
            Assert.NotNull(viewResult);

            AddressViewModel viewModel = viewResult.Model as AddressViewModel;
            Assert.NotNull(viewModel);

            Assert.Equal(new Guid("1B7329B9-DC7F-4621-8E97-FD97CDDDBA10"), viewModel.OrganisationId);
            Assert.Equal(OrganisationType.RegisteredCompany, viewModel.OrganisationType);
            Assert.Equal("Address Line 1", viewModel.Address.Address1);
        }
Ejemplo n.º 14
0
 public Organisation() {
   org_ = new OrganisationData();
   org_.Address = new AddressData();
   riskMaps_ = new List<Guid>();
 } // Organisation
Ejemplo n.º 15
0
 public OrganisationSummaryViewModel()
 {
     OrganisationData = new OrganisationData();
 }
Ejemplo n.º 16
0
    } // Organisation

    public Organisation(OrganisationData org) {
      org_ = org;
      riskMaps_ = org.RiskMaps();
    } // Organisation
Ejemplo n.º 17
0
        public void SetUpOrganisationTests()
        {
            _repository               = new RegisterRepository(_databaseService.WebConfiguration, new Mock <ILogger <RegisterRepository> >().Object);
            _organisationIdCreated    = "EPA987";
            _ukprnBefore              = 123321;
            _ukprnAfter               = 124421;
            _organisationTypeIdBefore = 5;
            _organisationTypeIdAfter  = 6;
            _updatedAt = DateTime.Today.Date.AddHours(9);
            OrganisationTypeHandler.InsertRecord(new OrganisationTypeModel {
                Id = _organisationTypeIdBefore, Status = "new", Type = "organisation type 1"
            });
            OrganisationTypeHandler.InsertRecord(new OrganisationTypeModel {
                Id = _organisationTypeIdAfter, Status = "new", Type = "organisation type 2"
            });
            _nameUpdated = "name 2";
            _createdAt   = DateTime.Today.Date.AddHours(8);

            _initialOrganisationDetails = new EpaOrganisation
            {
                Id                 = Guid.NewGuid(),
                CreatedAt          = _createdAt,
                Name               = "name 1",
                OrganisationId     = _organisationIdCreated,
                Ukprn              = _ukprnBefore,
                PrimaryContact     = null,
                PrimaryContactName = null,
                Status             = OrganisationStatus.New,
                OrganisationTypeId = _organisationTypeIdBefore,
                OrganisationData   = new OrganisationData
                {
                    LegalName   = " legal name",
                    TradingName = "trading name",
                    Address1    = "address 1",
                    Address2    = "address 2",
                    Address3    = "address 3",
                    Address4    = "address 4",
                    Postcode    = "postcode"
                }
            };

            _updatedOrgData = new OrganisationData
            {
                LegalName   = " legal name 2",
                TradingName = "trading name 2",
                Address1    = "address 1b",
                Address2    = "address 2b",
                Address3    = "address 3b",
                Address4    = "address 4b",
                Postcode    = "postcodeb"
            };

            _expectedOrganisationDetails = new EpaOrganisation
            {
                Id                 = _initialOrganisationDetails.Id,
                CreatedAt          = _createdAt,
                Name               = _nameUpdated,
                OrganisationId     = _organisationIdCreated,
                Ukprn              = _ukprnAfter,
                PrimaryContact     = null,
                PrimaryContactName = null,
                Status             = OrganisationStatus.New,
                UpdatedAt          = _updatedAt,
                OrganisationTypeId = _organisationTypeIdAfter,
                OrganisationData   = _updatedOrgData
            };
        }
Ejemplo n.º 18
0
 public UpdateOrganisationDetails(OrganisationData organisationData)
 {
     OrganisationData = organisationData;
 }
Ejemplo n.º 19
0
        public ActionResult AdministrationData(Administration data, string prevBtn, string nextBtn)
        {
            OrganisationData obj = GetOrgData();

            if (prevBtn != null)
            {
                Organisation ovm = new Organisation();

                ovm.Vision  = obj.OrgData.Vision;
                ovm.Mission = obj.OrgData.Mission;
                ovm.WomensRightsIssuesId = obj.OrgData.WomensRightsIssuesId;
                ovm.YearFormed           = obj.OrgData.YearFormed;
                ovm.Founder               = obj.OrgData.Founder;
                ovm.ReasonFormed          = obj.OrgData.ReasonFormed;
                ovm.OperationalAreaId     = obj.OrgData.OperationalAreaId;
                ovm.OperationalLocationId = obj.OrgData.OperationalLocationId;
                ovm.OperationalLocations  = obj.OrgData.OperationalLocations;
                ovm.Achievements          = obj.OrgData.Achievements;

                return(View("OrganisationData", ovm));
            }

            if (nextBtn != null)
            {
                //if (ModelState.IsValid)
                //{
                string previousGrantsJson = Request.Form["previousGrants"];
                _previousGrants = JsonConvert.DeserializeObject <HashSet <PreviousGrantsInformation> >(previousGrantsJson);

                obj.AdminData.Name = data.Name;

                obj.AdminData.PhysicalAddressLine1 = data.PhysicalAddressLine1;
                obj.AdminData.PhysicalAddressLine2 = data.PhysicalAddressLine2;
                obj.AdminData.PhysicalCity         = data.PhysicalCity;
                obj.AdminData.PhysicalCountry      = data.PhysicalCountry;
                obj.AdminData.PhysicalCode         = data.PhysicalCode;

                obj.AdminData.PostalAddressLine1 = data.PostalAddressLine1;
                obj.AdminData.PostalAddressLine2 = data.PostalAddressLine2;
                obj.AdminData.PostalCity         = data.PostalCity;
                obj.AdminData.PostalCountry      = data.PostalCountry;
                obj.AdminData.PostalCode         = data.PostalCode;

                obj.AdminData.TelephoneNumber = data.TelephoneNumber;
                obj.AdminData.MobileNumber    = data.MobileNumber;
                obj.AdminData.EmailAddress    = data.EmailAddress;
                obj.AdminData.WebsiteUrl      = data.WebsiteUrl;
                obj.AdminData.SkypeAddress    = data.SkypeAddress;
                obj.AdminData.TwitterAccount  = data.TwitterAccount;
                obj.AdminData.FacebookAccount = data.FacebookAccount;

                obj.AdminData.ContactName            = data.ContactName;
                obj.AdminData.ContactPosition        = data.ContactPosition;
                obj.AdminData.ContactTelephoneNumber = data.ContactTelephoneNumber;
                obj.AdminData.ContactEmailAddress    = data.ContactEmailAddress;
                obj.AdminData.ContactSkypeAddress    = data.ContactSkypeAddress;

                obj.AdminData.LearntAboutId              = data.LearntAboutId;
                obj.AdminData.ReceivedPreviousGrant      = data.ReceivedPreviousGrant;
                obj.AdminData.PreviousGrantInformationId = data.PreviousGrantInformationId;
                obj.AdminData.PreviousGrants             = _previousGrants;

                return(View("StructureData"));
                //}
            }

            return(View());
        }
Ejemplo n.º 20
0
        public async Task<ActionResult> EditSoleTraderOrIndividualOrganisationDetails(EditSoleTraderOrIndividualOrganisationDetailsViewModel model)
        {
            await SetBreadcrumb(model.SchemeId);

            if (!ModelState.IsValid)
            {
                using (var client = apiClient())
                {
                    model.BusinessAddress.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false));
                }
                return View(model);
            }

            using (var client = apiClient())
            {
                var orgData = new OrganisationData
                {
                    Id = model.OrgId,
                    OrganisationType = model.OrganisationType,
                    TradingName = model.BusinessTradingName,
                    BusinessAddress = model.BusinessAddress,
                };
                await client.SendAsync(User.GetAccessToken(), new UpdateOrganisationDetails(orgData));
            }

            return RedirectToAction("Overview", new { schemeId = model.SchemeId, overviewDisplayOption = OverviewDisplayOption.OrganisationDetails });
        }
 public ViewOrganisationDetailsViewModel()
 {
     OrganisationData = new OrganisationData();
 }
        public async Task UpdateOrganisationDetailsHandler_WithValidData_FetchesOrganisationAndUpdatesAndSaves()
        {
            // Arrange
            var organisationData = new OrganisationData
            {
                Id = new Guid("9a310218-311b-460d-bd50-9d246c237dcc"),
                OrganisationType          = OrganisationType.RegisteredCompany,
                Name                      = "CompanyName",
                CompanyRegistrationNumber = "123456789",
                OrganisationName          = "CompanyName",
                BusinessAddress           = new Core.Shared.AddressData
                {
                    Address1       = "Address1",
                    Address2       = "Address2",
                    TownOrCity     = "Town",
                    CountyOrRegion = "County",
                    Postcode       = "Postcode",
                    CountryId      = new Guid("79b70dfb-bbfd-4801-9849-880f66ee48e4"),
                    Telephone      = "012345678",
                    Email          = "*****@*****.**"
                }
            };

            var request = new UpdateOrganisationDetails(organisationData);

            var dataAccess        = A.Fake <IOrganisationDetailsDataAccess>();
            var weeeAuthorization = A.Fake <IWeeeAuthorization>();

            var organisation = A.Dummy <Organisation>();

            A.CallTo(() => dataAccess.FetchOrganisationAsync(new Guid("9a310218-311b-460d-bd50-9d246c237dcc")))
            .Returns(organisation);

            var country = new Country(
                new Guid("79b70dfb-bbfd-4801-9849-880f66ee48e4"),
                "Name");

            A.CallTo(() => dataAccess.FetchCountryAsync(new Guid("79b70dfb-bbfd-4801-9849-880f66ee48e4")))
            .Returns(country);

            var handler = new UpdateOrganisationDetailsHandler(dataAccess, weeeAuthorization);

            // Act
            var result = await handler.HandleAsync(request);

            // Assert
            A.CallTo(() => dataAccess.FetchOrganisationAsync(new Guid("9a310218-311b-460d-bd50-9d246c237dcc")))
            .MustHaveHappened(Repeated.Exactly.Once);

            Assert.Equal("CompanyName", organisation.Name);
            Assert.Equal("123456789", organisation.CompanyRegistrationNumber);
            Assert.Equal("Address1", organisation.BusinessAddress.Address1);
            Assert.Equal("Address2", organisation.BusinessAddress.Address2);
            Assert.Equal("Town", organisation.BusinessAddress.TownOrCity);
            Assert.Equal("County", organisation.BusinessAddress.CountyOrRegion);
            Assert.Equal("Postcode", organisation.BusinessAddress.Postcode);
            Assert.Equal(new Guid("79b70dfb-bbfd-4801-9849-880f66ee48e4"), organisation.BusinessAddress.Country.Id);
            Assert.Equal("012345678", organisation.BusinessAddress.Telephone);
            Assert.Equal("*****@*****.**", organisation.BusinessAddress.Email);

            A.CallTo(() => dataAccess.SaveAsync())
            .MustHaveHappened(Repeated.Exactly.Once);

            Assert.Equal(result, true);
        }
Ejemplo n.º 23
0
        public async Task<ActionResult> ManageContactDetails(OrganisationData model)
        {
            await SetBreadcrumb(model.Id, "Manage organisation contact details");

            if (!ModelState.IsValid)
            {
                using (var client = apiClient())
                {
                    model.OrganisationAddress.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false));
                }
                return View(model);
            }

            using (var client = apiClient())
            {
                await client.SendAsync(User.GetAccessToken(), new UpdateOrganisationContactDetails(model, true));
            }

            return RedirectToAction("ChooseActivity", new { pcsId = model.Id });
        }
Ejemplo n.º 24
0
 public ViewOrganisationDetailsViewModel()
 {
     OrganisationData = new OrganisationData();
 }
Ejemplo n.º 25
0
 public ReturnViewModel(ReturnData returnData, List <AatfObligatedData> obligatedTonnage, OrganisationData organisationData, TaskListDisplayOptions displayOptions) : base(returnData)
 {
     this.Year                   = returnData.Quarter.Year.ToString();
     this.AatfsData              = obligatedTonnage;
     this.Organisation           = organisationData;
     this.ReportOnDisplayOptions = displayOptions;
 }
Ejemplo n.º 26
0
        public async Task<ActionResult> ManageContactDetails(ManageContactDetailsViewModel model)
        {
            await SetBreadcrumb(model.SchemeId);

            if (!ModelState.IsValid)
            {
                using (var client = apiClient())
                {
                    model.OrganisationAddress.Countries = await client.SendAsync(User.GetAccessToken(), new GetCountries(false));
                }
                return View(model);
            }

            using (var client = apiClient())
            {
                var orgData = new OrganisationData
                {
                    Id = model.OrgId,
                    Contact = model.Contact,
                    OrganisationAddress = model.OrganisationAddress,
                };
                await client.SendAsync(User.GetAccessToken(), new UpdateOrganisationContactDetails(orgData));
            }

            return RedirectToAction("Overview", new { schemeId = model.SchemeId, overviewDisplayOption = OverviewDisplayOption.ContactDetails });
        }
        public async Task PostType_TypeDetailsSelectionWithOrganisationId_RedirectsToCorrectControllerAction(OrganisationType type, string action)
        {
            // Arrange
            OrganisationData orgData = new OrganisationData
            {
                OrganisationType = type,
                Id = Guid.NewGuid()
            };

            IWeeeClient weeeClient = A.Fake<IWeeeClient>();
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<VerifyOrganisationExistsAndIncomplete>._))
                .Returns(true);
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetOrganisationInfo>._))
                .Returns(orgData);

            ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>();

            OrganisationRegistrationController controller = new OrganisationRegistrationController(
                () => weeeClient,
                organisationSearcher);

            OrganisationTypeViewModel model = new OrganisationTypeViewModel(
                type,
                new Guid("35EFE82E-0706-4E80-8AFA-D81C4B58102A"));

            // Act
            ActionResult result = await controller.Type(model);

            // Assert
            var redirectToRouteResult = ((RedirectToRouteResult)result);

            Assert.Equal(action, redirectToRouteResult.RouteValues["action"]);
        }
Ejemplo n.º 28
0
 public AatfDataList(Guid id, string name, UKCompetentAuthorityData competentAuthority, string approvalNumber, AatfStatus aatfStatus, OrganisationData organisation, FacilityType facilityType, Int16 complianceYear, Guid aatfId, DateTime?approvalDate)
 {
     this.Id                 = id;
     this.Name               = name;
     this.ApprovalNumber     = approvalNumber;
     this.AatfStatus         = aatfStatus;
     this.AatfStatusString   = aatfStatus.DisplayName;
     this.CompetentAuthority = competentAuthority;
     this.Organisation       = organisation;
     this.FacilityType       = facilityType;
     this.ComplianceYear     = complianceYear;
     this.AatfId             = aatfId;
     this.ApprovalDate       = approvalDate;
 }
        public async Task GetRegisteredCompanyDetails_WithValidOrganisationId_ReturnsRegisteredCompanyDetailsViewWithModel()
        {
            // Arrange
            OrganisationData orgData = new OrganisationData
            {
                OrganisationType = OrganisationType.RegisteredCompany,
                Id = Guid.NewGuid(),
                TradingName = "TEST Ltd.",
                CompanyRegistrationNumber = "12345678",
                Name = "TEST"
            };

            IWeeeClient weeeClient = A.Fake<IWeeeClient>();
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<VerifyOrganisationExistsAndIncomplete>._))
                .Returns(true);
            A.CallTo(() => weeeClient.SendAsync(A<string>._, A<GetOrganisationInfo>._))
                .Returns(orgData);

            ISearcher<OrganisationSearchResult> organisationSearcher = A.Dummy<ISearcher<OrganisationSearchResult>>();

            OrganisationRegistrationController controller = new OrganisationRegistrationController(
                () => weeeClient,
                organisationSearcher);

            // Act
            ActionResult result = await controller.RegisteredCompanyDetails(orgData.Id);

            // Assert
            var model = ((ViewResult)result).Model;

            Assert.NotNull(model);
            Assert.IsType<RegisteredCompanyDetailsViewModel>(model);
            Assert.Equal(orgData.TradingName, ((RegisteredCompanyDetailsViewModel)model).BusinessTradingName);
            Assert.Equal(orgData.CompanyRegistrationNumber, ((RegisteredCompanyDetailsViewModel)model).CompaniesRegistrationNumber);
            Assert.Equal(orgData.Name, ((RegisteredCompanyDetailsViewModel)model).CompanyName);
        }
Ejemplo n.º 30
0
        public async Task <Guid?> CreateOrganisation(CreateOrganisationCommand command)
        {
            using (var connection = new SqlConnection(_configuration.SqlConnectionString))
            {
                if (connection.State != ConnectionState.Open)
                {
                    await connection.OpenAsync();
                }

                var startDate          = command.StartDate;
                var organisationId     = Guid.NewGuid();
                var createdAt          = DateTime.Now;
                var createdBy          = command.Username;
                var providerTypeId     = command.ProviderTypeId;
                var organisationTypeId = command.OrganisationTypeId;
                var statusId           = command.OrganisationStatusId;
                var organisationData   = new OrganisationData
                {
                    CompanyNumber          = command.CompanyNumber?.ToUpper(),
                    CharityNumber          = command.CharityNumber,
                    ParentCompanyGuarantee = command.ParentCompanyGuarantee,
                    FinancialTrackRecord   = command.FinancialTrackRecord,
                    NonLevyContract        = command.NonLevyContract,
                    StartDate                 = startDate,
                    SourceIsUKRLP             = command.SourceIsUKRLP,
                    ApplicationDeterminedDate = command.ApplicationDeterminedDate
                };

                string sql = $"INSERT INTO [dbo].[Organisations] " +
                             " ([Id] " +
                             ",[CreatedAt] " +
                             ",[CreatedBy] " +
                             ",[StatusId] " +
                             ",[ProviderTypeId] " +
                             ",[OrganisationTypeId] " +
                             ",[UKPRN] " +
                             ",[LegalName] " +
                             ",[TradingName] " +
                             ",[StatusDate] " +
                             ",[OrganisationData]) " +
                             "VALUES " +
                             "(@organisationId, @createdAt, @createdBy, @statusId, @providerTypeId, @organisationTypeId," +
                             " @ukprn, @legalName, @tradingName, @statusDate, @organisationData)";

                var organisationsCreated = await connection.ExecuteAsync(sql,
                                                                         new
                {
                    organisationId,
                    createdAt,
                    createdBy,
                    statusId,
                    providerTypeId,
                    organisationTypeId,
                    command.Ukprn,
                    command.LegalName,
                    command.TradingName,
                    command.StatusDate,
                    organisationData
                });

                var success = await Task.FromResult(organisationsCreated > 0);

                if (success)
                {
                    return(organisationId);
                }

                return(null);
            }
        }
Ejemplo n.º 31
0
        public ActionResult AdministrationData(AdministrationData data, string prevBtn, string nextBtn)
        {
            WizardModel obj = GetWizard();

            if (prevBtn != null)
            {
                OrganisationData od = new OrganisationData();

                od.Vision  = obj.OrgData.Vision;
                od.Mission = obj.OrgData.Mission;
                od.WomensRightsIssuesId = obj.OrgData.WomensRightsIssuesId;
                od.YearFormed           = obj.OrgData.YearFormed;
                od.Founder               = obj.OrgData.Founder;
                od.ReasonFormed          = obj.OrgData.ReasonFormed;
                od.OperationalAreaId     = obj.OrgData.OperationalAreaId;
                od.OperationalLocationId = obj.OrgData.OperationalLocationId;
                od.Achievements          = obj.OrgData.Achievements;

                return(View("OrganisationData"));
            }

            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    obj.AdminData.Name = data.Name;

                    obj.AdminData.PhysicalAddressLine1 = data.PhysicalAddressLine1;
                    obj.AdminData.PhysicalAddressLine2 = data.PhysicalAddressLine2;
                    obj.AdminData.PhysicalCity         = data.PhysicalCity;
                    obj.AdminData.PhysicalCountry      = data.PhysicalCountry;
                    obj.AdminData.PhysicalCode         = data.PhysicalCode;

                    obj.AdminData.PostalAddressLine1 = data.PostalAddressLine1;
                    obj.AdminData.PostalAddressLine2 = data.PostalAddressLine2;
                    obj.AdminData.PostalCity         = data.PostalCity;
                    obj.AdminData.PostalCountry      = data.PostalCountry;
                    obj.AdminData.PostalCode         = data.PostalCode;

                    obj.AdminData.TelephoneNumber = data.TelephoneNumber;
                    obj.AdminData.MobileNumber    = data.MobileNumber;
                    obj.AdminData.EmailAddress    = data.EmailAddress;
                    obj.AdminData.WebsiteUrl      = data.WebsiteUrl;
                    obj.AdminData.SkypeAddress    = data.SkypeAddress;
                    obj.AdminData.TwitterAccount  = data.TwitterAccount;
                    obj.AdminData.FacebookAccount = data.FacebookAccount;

                    obj.AdminData.ContactName            = data.ContactName;
                    obj.AdminData.ContactPosition        = data.ContactPosition;
                    obj.AdminData.ContactTelephoneNumber = data.ContactTelephoneNumber;
                    obj.AdminData.ContactEmailAddress    = data.ContactEmailAddress;
                    obj.AdminData.ContactSkypeAddress    = data.ContactSkypeAddress;

                    obj.AdminData.LearntAboutId              = data.LearntAboutId;
                    obj.AdminData.ReceivedPreviousGrant      = data.ReceivedPreviousGrant;
                    obj.AdminData.PreviousGrantInformationId = data.PreviousGrantInformationId;

                    return(View("StructureData"));
                }
            }

            return(View());
        }
Ejemplo n.º 32
0
        public ActionResult StructureData(Structure data, string prevBtn, string nextBtn, HttpPostedFileBase upload, HttpPostedFileBase refLetter)
        {
            OrganisationData obj = GetOrgData();

            if (prevBtn != null)
            {
                if (ModelState.IsValid)
                {
                    Administration avm = new Administration();

                    avm.Name = obj.AdminData.Name;

                    avm.PhysicalAddressLine1 = obj.AdminData.PhysicalAddressLine1;
                    avm.PhysicalAddressLine2 = obj.AdminData.PhysicalAddressLine2;
                    avm.PhysicalCity         = obj.AdminData.PhysicalCity;
                    avm.PhysicalCountry      = obj.AdminData.PhysicalCountry;
                    avm.PhysicalCode         = obj.AdminData.PhysicalCode;

                    avm.PostalAddressLine1 = obj.AdminData.PostalAddressLine1;
                    avm.PostalAddressLine2 = obj.AdminData.PostalAddressLine2;
                    avm.PostalCity         = obj.AdminData.PostalCity;
                    avm.PostalCountry      = obj.AdminData.PostalCountry;
                    avm.PostalCode         = obj.AdminData.PostalCode;

                    avm.TelephoneNumber = obj.AdminData.TelephoneNumber;
                    avm.MobileNumber    = obj.AdminData.MobileNumber;
                    avm.EmailAddress    = obj.AdminData.EmailAddress;
                    avm.WebsiteUrl      = obj.AdminData.WebsiteUrl;
                    avm.SkypeAddress    = obj.AdminData.SkypeAddress;
                    avm.TwitterAccount  = obj.AdminData.TwitterAccount;
                    avm.FacebookAccount = obj.AdminData.FacebookAccount;

                    avm.ContactName            = obj.AdminData.ContactName;
                    avm.ContactPosition        = obj.AdminData.ContactPosition;
                    avm.ContactTelephoneNumber = obj.AdminData.ContactTelephoneNumber;
                    avm.ContactEmailAddress    = obj.AdminData.ContactEmailAddress;
                    avm.ContactSkypeAddress    = obj.AdminData.ContactSkypeAddress;

                    avm.LearntAboutId              = obj.AdminData.LearntAboutId;
                    avm.ReceivedPreviousGrant      = obj.AdminData.ReceivedPreviousGrant;
                    avm.PreviousGrantInformationId = obj.AdminData.PreviousGrantInformationId;
                    avm.PreviousGrants             = obj.AdminData.PreviousGrants;

                    return(View("AdministrationData", avm));
                }
            }

            if (nextBtn != null)
            {
                if (ModelState.IsValid)
                {
                    // file saving code : https://www.mikesdotnetting.com/article/259/asp-net-mvc-5-with-ef-6-working-with-files
                    var uploadedFiles = new List <File>();

                    if (upload != null && upload.ContentLength > 0)
                    {
                        var registrationCertificate = new File()
                        {
                            FileName    = System.IO.Path.GetFileName(upload.FileName),
                            FileType    = FileType.RegistrationCertificate,
                            ContentType = upload.ContentType
                        };

                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            registrationCertificate.Content = reader.ReadBytes(upload.ContentLength);
                        }
                        //data.Files = new List<File> {registrationCertiificate};
                        uploadedFiles.Add(registrationCertificate);
                        data.Files = uploadedFiles;
                    }

                    if (refLetter != null && refLetter.ContentLength > 0)
                    {
                        var referenceLetter = new File()
                        {
                            FileName    = System.IO.Path.GetFileName(refLetter.FileName),
                            FileType    = FileType.ReferenceLetter,
                            ContentType = refLetter.ContentType
                        };

                        using (var reader = new System.IO.BinaryReader(refLetter.InputStream))
                        {
                            referenceLetter.Content = reader.ReadBytes(refLetter.ContentLength);
                        }

                        uploadedFiles.Add(referenceLetter);
                        data.Files = uploadedFiles;
                    }

                    obj.StructData.IsWomensRightsOrganisation     = data.IsWomensRightsOrganisation;
                    obj.StructData.WomensRightsPhiliosophy        = data.WomensRightsPhiliosophy;
                    obj.StructData.WomensRoleInDecisionMaking     = data.WomensRoleInDecisionMaking;
                    obj.StructData.HowAreKeyDecisionsMade         = data.HowAreKeyDecisionsMade;
                    obj.StructData.WomensRoleOnBoard              = data.WomensRoleOnBoard;
                    obj.StructData.PaidStaffTotal                 = data.PaidStaffTotal;
                    obj.StructData.PaidStaffFemales               = data.PaidStaffFemales;
                    obj.StructData.PaidStaffMales                 = data.PaidStaffMales;
                    obj.StructData.PaidStaffTransNonConforming    = data.PaidStaffTransNonConforming;
                    obj.StructData.UnpaidStaffTotal               = data.UnpaidStaffTotal;
                    obj.StructData.UnpaidStaffFemales             = data.UnpaidStaffFemales;
                    obj.StructData.UnpaidStaffMales               = data.UnpaidStaffMales;
                    obj.StructData.UnpaidStaffTransNonConforming  = data.UnpaidStaffTransNonConforming;
                    obj.StructData.BoardMembersTotal              = data.BoardMembersTotal;
                    obj.StructData.BoardMembersFemales            = data.BoardMembersFemales;
                    obj.StructData.BoardMembersMales              = data.BoardMembersMales;
                    obj.StructData.BoardMembersTransNonConforming = data.BoardMembersTransNonConforming;
                    obj.StructData.AdvisorsTotal                = data.AdvisorsTotal;
                    obj.StructData.AdvisorsFemales              = data.AdvisorsFemales;
                    obj.StructData.AdvisorsMales                = data.AdvisorsMales;
                    obj.StructData.AdvisorsTransNonConforming   = data.AdvisorsTransNonConforming;
                    obj.StructData.VolunteersTotal              = data.VolunteersTotal;
                    obj.StructData.VolunteersFemales            = data.VolunteersFemales;
                    obj.StructData.VolunteersMales              = data.VolunteersMales;
                    obj.StructData.VolunteersTransNonConforming = data.VolunteersTransNonConforming;
                    obj.StructData.MembersTotal              = data.MembersTotal;
                    obj.StructData.MembersFemales            = data.MembersFemales;
                    obj.StructData.MembersMales              = data.MembersMales;
                    obj.StructData.MembersTransNonConforming = data.MembersTransNonConforming;
                    obj.StructData.Files = data.Files;

                    // save data here
                    _uow.Repository <Organisation>().Add(obj.OrgData);
                    _uow.Repository <Administration>().Add(obj.AdminData);
                    _uow.Repository <Structure>().Add(obj.StructData);

                    _uow.SaveChanges();
                    RemoveOrgData();

                    return(View("Success"));
                }
            }
            return(View());
        }