Beispiel #1
0
        public async Task Arrange()
        {
            MappingBootstrapper.Initialize();

            var organisations = new List <Organisation>
            {
                Builder <Organisation> .CreateNew()
                .With(q => q.EndPointAssessorUkprn = 10000000)
                .Build()
            }.AsQueryable();

            var mockSet       = organisations.CreateMockSet(organisations);
            var mockDbContext = CreateMockDbContext(mockSet);

            _organisationRepository = new OrganisationRepository(mockDbContext.Object);

            try
            {
                await _organisationRepository.Delete("123456");
            }
            catch (Exception exception)
            {
                _exception = exception;
            }
        }
Beispiel #2
0
 public void setup_organisation_is_added()
 {
     _organisationStatusId1 = 1;
     _providerTypeId1       = 10;
     _organisationTypeId1   = 100;
     _organisationUkprn     = 11114433;
     _legalName             = "Legal name 1";
     _organisationId        = Guid.NewGuid();
     _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);
     _organisation = new OrganisationModel
     {
         UKPRN = _organisationUkprn,
         OrganisationTypeId = _organisationTypeId1,
         ProviderTypeId     = _providerTypeId1,
         StatusId           = _organisationStatusId1,
         StatusDate         = DateTime.Today.AddDays(5),
         LegalName          = _legalName,
         Id        = _organisationId,
         CreatedAt = DateTime.Now,
         CreatedBy = "Test"
     };
     OrganisationHandler.InsertRecord(_organisation);
 }
        public async Task <IActionResult> GetOrganisationsForUser(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "Organisation/GetOrganisationsForUser")] HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function(GetOrganisationsForUser) processed a request.");

            try
            {
                var accessTokenResult = _tokenProvider.ValidateToken(req);

                if (accessTokenResult.Status == AccessTokenStatus.Valid)
                {
                    Guid userAccountId = new Guid(accessTokenResult.Principal.Claims.First(c => c.Type == "UserAccount").Value);
                    log.LogInformation($"JWT validated for UserAccount: {userAccountId}.");

                    // we might not need OrganisationMembershipFunctions??
                    var organisationRepository = new OrganisationRepository();
                    var organisations          = organisationRepository.GetOrganisationsForUser(userAccountId);

                    return(new OkObjectResult(organisations));
                }

                else
                {
                    return(new UnauthorizedResult());
                }
            }
            catch (Exception exception)
            {
                return(new BadRequestObjectResult(exception.Message));
            }
        }
Beispiel #4
0
 public void Before_the_tests()
 {
     _organisationTypeId1 = 1;
     _repository          = new OrganisationRepository(_databaseService.WebConfiguration);
     _statusActive        = new OrganisationStatusModel {
         Id = _organisationStatusIdActive, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
     };
     _statusOnboarding = new OrganisationStatusModel {
         Id = _organisationStatusIdOnboarding, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
     };
     OrganisationStatusHandler.InsertRecord(_statusActive);
     OrganisationStatusHandler.InsertRecord(_statusOnboarding);
     _providerType1 = new ProviderTypeModel {
         Id = _providerTypeIdMainProvider, ProviderType = "Main Provider", Description = "provider type description 1", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
     };
     _providerType2 = new ProviderTypeModel {
         Id = _providerTypeIdEmployerProvider, ProviderType = "Employer Provider", Description = "provider type description 2", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
     };
     _providerType3 = new ProviderTypeModel {
         Id = _providerTypeIdSupportingProvider, ProviderType = "Supporting Provider", Description = "provider type description 3", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
     };
     ProviderTypeHandler.InsertRecords(new List <ProviderTypeModel> {
         _providerType1, _providerType2, _providerType3
     });
     _organisationTypeModel1 = new OrganisationTypeModel {
         Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
     };
     OrganisationTypeHandler.InsertRecord(_organisationTypeModel1);
 }
Beispiel #5
0
        public async Task TestHarvestOrgs_OK()
        {
            Mock <ILogger <OrganisationRepository> > loggerMock = new Mock <ILogger <OrganisationRepository> >();

            GeneralSettings generalSettings = new GeneralSettings {
                OrganisationRepositoryLocation = "https://altinncdn.no/orgs/altinn-orgs.json"
            };

            Mock <IOptions <GeneralSettings> > optionsMock = new Mock <IOptions <GeneralSettings> >();

            optionsMock.Setup(o => o.Value).Returns(generalSettings);

            OrganisationRepository orgRepo = new OrganisationRepository(loggerMock.Object, optionsMock.Object);

            string org = await orgRepo.LookupOrg("974760223");

            Assert.Equal("dibk", org);

            string orgNumber = await orgRepo.LookupOrgNumber("brg");

            Assert.Equal("974760673", orgNumber);

            Organisation organisation = await orgRepo.GetOrganisationByOrg("nb");

            Assert.Equal("National Library of Norway", organisation.Name["en"]);
        }
Beispiel #6
0
        public MessageFactory()
        {
            var entities = new Entities();

            mRepository = new MessageRepository(entities);
            oRepository = new OrganisationRepository(entities);
        }
        public void GetByIdTest()
        {
            var orgrepo = new OrganisationRepository(orgcontextmock.Object);
            var org     = orgrepo.GetById(4);

            Assert.AreEqual(4, org.Id);
        }
        public void GetAllTest()
        {
            var OrganizationsRepo = new OrganisationRepository(orgcontextmock.Object);
            var orglist           = OrganizationsRepo.Get();

            Assert.AreEqual(4, orglist.Count());
        }
        public void Set_up_and_run_update()
        {
            _organisationStatusId1        = 1;
            _organisationStatusId0        = 0;
            _providerTypeId1              = 10;
            _organisationTypeId1          = 100;
            _organisationUkprn            = 11114433;
            _legalName                    = "Legal name 1";
            _organisationId               = Guid.NewGuid();
            _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper);
            _repository                   = new OrganisationRepository(_databaseService.DbConnectionHelper);
            _status1 = new OrganisationStatusModel {
                Id = _organisationStatusId1, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
            };
            OrganisationStatusHandler.InsertRecord(_status1);
            _status2 = new OrganisationStatusModel {
                Id = _organisationStatusId0, Status = "Live", CreatedAt = DateTime.Now, CreatedBy = "TestSystem"
            };
            OrganisationStatusHandler.InsertRecord(_status2);
            _reason1 = new RemovedReasonModel {
                Id = 1, CreatedBy = "System", Reason = "Test reason", Status = "Live"
            };
            RemovedReasonHandler.InsertRecord(_reason1);
            _reason2 = new RemovedReasonModel {
                Id = 2, CreatedBy = "System", Reason = "Test reason 2", Status = "Live"
            };
            RemovedReasonHandler.InsertRecord(_reason2);
            _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 json = "{ \"CompanyNumber\":\"12345678\",\"CharityNumber\":\"1234567\",\"ParentCompanyGuarantee\":false,\"FinancialTrackRecord\":true,\"NonLevyContract\":false,\"StartDate\":\"2019-03-27 00:00:00\",\"RemovedReason\":{\"Id\":1,\"Reason\":\"Test reason\",\"Description\":null,\"CreatedBy\":\"System\",\"CreatedAt\":\"2019-02-11 15:47:23\",\"UpdatedBy\":null,\"UpdatedAt\":null,\"Status\":\"Live\"}}";

            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId1,
                ProviderTypeId     = _providerTypeId1,
                StatusId           = _organisationStatusId1,
                StatusDate         = DateTime.Today.AddDays(5),
                LegalName          = _legalName,
                Id               = _organisationId,
                CreatedAt        = DateTime.Now,
                CreatedBy        = "Test",
                OrganisationData = json
            };
            OrganisationHandler.InsertRecord(_organisation);
            _changedBy = "SystemChange";

            var _updatedReason = _updateOrganisationRepository.UpdateStatusWithRemovedReason(_organisationId, _organisationStatusId0, _reason2.Id, _changedBy).Result;

            _successfulUpdate        = (_updatedReason != null);
            _newOrganisationStatusId = _repository.GetOrganisationStatus(_organisationId).Result;
        }
Beispiel #10
0
        public OrganisationRepositoryTests()
        {
            var gitHubClientMock = new Mock <IGitHubClient>();

            _organizationsClientMock = new Mock <IOrganizationsClient>();
            gitHubClientMock.SetupGet(x => x.Organization).Returns(_organizationsClientMock.Object);

            _sut = new OrganisationRepository(gitHubClientMock.Object);
        }
Beispiel #11
0
 public EventFactory()
 {
     eRepository  = new EventRepository(new Entities());
     lRepository  = new LocationRepository(new Entities());
     oRepository  = new OrganisationRepository(new Entities());
     teRepository = new TypeEventRepository(new Entities());
     pRepository  = new PictureRepository(new Entities());
     edRepository = new EventDateRepository(new Entities());
 }
Beispiel #12
0
        public async Task<ActionResult> Index()
        {
            var orgRepo = new OrganisationRepository();

            var currentUser = new List<string>();
            currentUser.Add(User.Identity.Name);

            var model = await orgRepo.GetOrganisations(User.Identity.Name);
            return View(model);
        }
Beispiel #13
0
        public TicketFactory()
        {
            var entities = new Entities();

            tRepository   = new TicketRepository(entities);
            tiRepository  = new TicketInventoryRepository(entities);
            oRepository   = new OrganisationRepository(entities);
            eRepository   = new EventRepository(entities);
            trRespository = new TicketReservationRepository(entities);
        }
        public void PostOrganizationTest()
        {
            var orgrepo = new OrganisationRepository(orgcontextmock.Object);
            var org     = orgrepo.Add2(new Organization()
            {
                Id = 9, OrganizationName = "tnt", TotalDonations = "10000"
            });

            Assert.AreEqual(9, org.Id);
        }
        public OrganisationFactory()
        {
            var entities = new Entities();

            oRepository  = new OrganisationRepository(entities);
            toRepository = new TypeOrganisationRepository(entities);
            lRepository  = new LocationRepository(entities);
            eRepository  = new EventRepository(entities);
            tiRepository = new TicketInventoryRepository(entities);
            mRepository  = new MessageRepository(entities);
            trRepository = new TicketReservationRepository(entities);
        }
        public void OrganisationRepository_GetOrganisations_ShouldReturnOneOrganisation()
        {
            var list = new List <Organisation>()
            {
                new Organisation()
            };
            var organisationRepository = new OrganisationRepository(list);
            var test = organisationRepository.GetOrganisations().ToList();

            Assert.IsNotNull(test);
            Assert.AreEqual(1, test.Count);
        }
        public async Task <IActionResult> CreateOrganisation(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "Organisation/CreateOrganisation")] HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function(CreateOrganisation) processed a request.");

            try
            {
                var accessTokenResult = _tokenProvider.ValidateToken(req);

                if (accessTokenResult.Status == AccessTokenStatus.Valid)
                {
                    Guid userAccountId = new Guid(accessTokenResult.Principal.Claims.First(c => c.Type == "UserAccount").Value);
                    log.LogInformation($"JWT validated for UserAccount: {userAccountId}.");

                    string requestBody             = await new StreamReader(req.Body).ReadToEndAsync();
                    var    organisationCreateModel = JsonConvert.DeserializeObject <OrganisationCreateModel>(requestBody);

                    var organisation = new Organisation()
                    {
                        OrganisationName = organisationCreateModel.OrganisationName,
                        CreatedById      = userAccountId
                    };

                    var organisationRepo = new OrganisationRepository();
                    var organisationId   = organisationRepo.CreateOrganisation(organisation);

                    var organisationMembership = new OrganisationMembership()
                    {
                        OrganisationId       = organisationId,
                        UserAccountId        = userAccountId,
                        UserType             = UserType.OrganisationOwner,
                        OrganisationInviteId = null
                    };

                    // store the OrganisationMembership
                    var organisationMembershipRepo = new OrganisationMembershipRepository();
                    organisationMembershipRepo.CreateOrganisationMembership(organisationMembership);

                    // create JWT with the OrganisationId as
                    var jwt = _tokenCreator.CreateToken(userAccountId, organisationId);
                    return(new OkObjectResult(jwt));
                }
                else
                {
                    return(new UnauthorizedResult());
                }
            }
            catch (Exception exception)
            {
                return(new BadRequestObjectResult(exception.Message));
            }
        }
Beispiel #18
0
        public void Arrange()
        {
            MappingBootstrapper.Initialize();

            var organisation = Builder <Organisation> .CreateNew().Build();

            var mockSet = CreateMockDbSet();

            _mockDbContext = CreateMockDbContext(mockSet);

            _organisationRepository = new OrganisationRepository(_mockDbContext.Object);
            _result = _organisationRepository.CreateNewOrganisation(organisation).Result;
        }
Beispiel #19
0
        public void Set_up_data()
        {
            event1CreatedOn = DateTime.Today;
            event2CreatedOn = DateTime.Today.AddDays(-1);
            event3CreatedOn = DateTime.Today.AddDays(-2);
            event4CreatedOn = DateTime.Today.AddDays(-3);
            event5CreatedOn = DateTime.Today.AddDays(-4);
            event6CreatedOn = DateTime.Today.AddDays(-5);

            _repository = new OrganisationRepository(_databaseService.DbConnectionHelper);

            OrganisationStatusHandler.InsertRecord(new OrganisationStatusModel {
                Id = OrganisationStatus.Active, CreatedAt = DateTime.Now, CreatedBy = "system", Status = "Active", EventDescription = "ACTIVE"
            });
            OrganisationStatusHandler.InsertRecord(new OrganisationStatusModel {
                Id = OrganisationStatus.Onboarding, CreatedAt = DateTime.Now, CreatedBy = "system", Status = "Onboarding", EventDescription = "INITIATED"
            });
            OrganisationStatusHandler.InsertRecord(new OrganisationStatusModel {
                Id = OrganisationStatus.ActiveNotTakingOnApprentices, CreatedAt = DateTime.Now, CreatedBy = "system", Status = "active not taking", EventDescription = "ACTIVENOSTARTS"
            });
            OrganisationStatusHandler.InsertRecord(new OrganisationStatusModel {
                Id = OrganisationStatus.Removed, CreatedAt = DateTime.Now, CreatedBy = "system", Status = "Removed", EventDescription = "REMOVED"
            });

            event1Active = new OrganisationStatusEventModel {
                Id = 1, CreatedOn = event1CreatedOn, OrganisationStatusId = OrganisationStatus.Active, ProviderId = 11112221
            };
            event2Onboarding = new OrganisationStatusEventModel {
                Id = 2, CreatedOn = event2CreatedOn, OrganisationStatusId = OrganisationStatus.Onboarding, ProviderId = 11112222
            };
            event3Active = new OrganisationStatusEventModel {
                Id = 3, CreatedOn = event3CreatedOn, OrganisationStatusId = OrganisationStatus.Active, ProviderId = 11112223
            };
            event4Removed = new OrganisationStatusEventModel {
                Id = 4, CreatedOn = event4CreatedOn, OrganisationStatusId = OrganisationStatus.Removed, ProviderId = 11112224
            };
            event5ActiveNotTaking = new OrganisationStatusEventModel {
                Id = 5, CreatedOn = event5CreatedOn, OrganisationStatusId = OrganisationStatus.ActiveNotTakingOnApprentices, ProviderId = 11112225
            };
            event6Active = new OrganisationStatusEventModel {
                Id = 6, CreatedOn = event6CreatedOn, OrganisationStatusId = OrganisationStatus.Active, ProviderId = 11112226
            };


            OrganisationStatusEventHandler.InsertRecord(event1Active);
            OrganisationStatusEventHandler.InsertRecord(event2Onboarding);
            OrganisationStatusEventHandler.InsertRecord(event3Active);
            OrganisationStatusEventHandler.InsertRecord(event4Removed);
            OrganisationStatusEventHandler.InsertRecord(event5ActiveNotTaking);
            OrganisationStatusEventHandler.InsertRecord(event6Active);
        }
        public void Set_up_and_run_update()
        {
            _organisationStatusId1        = 1;
            _providerTypeId1              = 10;
            _providerTypeId2              = 20;
            _organisationTypeId1          = 100;
            _organisationTypeId2          = 111;
            _organisationUkprn            = 11114433;
            _legalName                    = "Legal name 1";
            _organisationId               = Guid.NewGuid();
            _updateOrganisationRepository = new UpdateOrganisationRepository(_databaseService.DbConnectionHelper);
            _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);
            _providerType2 = new ProviderTypeModel {
                Id = _providerTypeId2, ProviderType = "provider type 12", Description = "provider type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            ProviderTypeHandler.InsertRecord(_providerType2);
            _organisationTypeModel1 = new OrganisationTypeModel {
                Id = _organisationTypeId1, Type = "organisation type 10", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            OrganisationTypeHandler.InsertRecord(_organisationTypeModel1);
            _organisationTypeModel2 = new OrganisationTypeModel {
                Id = _organisationTypeId2, Type = "organisation type 22", Description = "organisation type description", CreatedAt = DateTime.Now, CreatedBy = "TestSystem", Status = "Live"
            };
            OrganisationTypeHandler.InsertRecord(_organisationTypeModel2);
            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId1,
                ProviderTypeId     = _providerTypeId1,
                StatusId           = _organisationStatusId1,
                StatusDate         = DateTime.Today.AddDays(5),
                LegalName          = _legalName,
                Id        = _organisationId,
                CreatedAt = DateTime.Now,
                CreatedBy = "Test"
            };
            OrganisationHandler.InsertRecord(_organisation);
            _changedBy = "SystemChange";

            _successfulUpdate    = _updateOrganisationRepository.UpdateProviderTypeAndOrganisationType(_organisationId, _providerTypeId2, _organisationTypeId2, _changedBy).Result;
            _newProviderType     = _repository.GetProviderType(_organisationId).Result;
            _newOrganisationType = _repository.GetOrganisationType(_organisationId).Result;
        }
        public async Task <IActionResult> DeleteOrganisation(
            [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "Organisation/DeleteOrganisation")] HttpRequest req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function(DeleteOrganisation) processed a request.");

            try
            {
                // Validate JWT
                var accessTokenResult = _tokenProvider.ValidateToken(req);
                if (accessTokenResult.Status != AccessTokenStatus.Valid)
                {
                    return(new UnauthorizedResult());
                }

                string requestBody            = await new StreamReader(req.Body).ReadToEndAsync();
                var    userAccountCreateModel = JsonConvert.DeserializeObject <UserAccountCreateModel>(requestBody);

                // Validate Email/Password
                var loginManager = new LoginManager();
                var loginResult  = loginManager.AttemptLogin(userAccountCreateModel.EmailAddress, userAccountCreateModel.Password);
                if (loginResult.Status != LoginStatus.Success)
                {
                    return(new BadRequestObjectResult(loginResult.FailureReason));
                }

                Guid userAccountId  = new Guid(accessTokenResult.Principal.Claims.First(c => c.Type == "UserAccount").Value);
                Guid organisationId = new Guid(accessTokenResult.Principal.Claims.First(c => c.Type == "Organisation").Value);

                // Make sure this UserAccount is the Organisation Owner
                var organisationMembershipRepository = new OrganisationMembershipRepository();
                var organisationMembership           = organisationMembershipRepository.GetOrganisationMembership(userAccountId, organisationId);

                if (organisationMembership.UserType == UserType.OrganisationOwner)
                {
                    var  organisationRepo = new OrganisationRepository();
                    bool deleted          = organisationRepo.DeleteOrganisation(organisationId);

                    return(new OkObjectResult(deleted));
                }
                else
                {
                    return(new UnauthorizedResult());
                }
            }
            catch (Exception exception)
            {
                return(new BadRequestObjectResult(exception.Message));
            }
        }
        static void Main(string[] args)
        {
            var dataService = new JsonToModelConverterService();

            var searchMethod           = new PropertyValueSearch();
            var organisationRepository = new OrganisationRepository(dataService.GetModelsFromFile <Organisation>("organizations.json"));
            var ticketRepository       = new TicketRepository(dataService.GetModelsFromFile <Ticket>("tickets.json"));
            var userRepository         = new UserRepository(dataService.GetModelsFromFile <User>("users.json"));

            SearchAppLauncher app = new SearchAppLauncher(organisationRepository, ticketRepository, userRepository, searchMethod);

            app.Start(args);

            Console.Read();
        }
        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 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;
        }
Beispiel #25
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
#pragma warning disable CS0433 // The type 'Batteries' exists in both 'SQLitePCLRaw.batteries_green, Version=1.1.13.388, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f' and 'SQLitePCLRaw.batteries_v2, Version=2.0.2.669, Culture=neutral, PublicKeyToken=8226ea5df37bcae9'
            SQLitePCL.Batteries.Init();
#pragma warning restore CS0433 // The type 'Batteries' exists in both 'SQLitePCLRaw.batteries_green, Version=1.1.13.388, Culture=neutral, PublicKeyToken=a84b7dcfb1391f7f' and 'SQLitePCLRaw.batteries_v2, Version=2.0.2.669, Culture=neutral, PublicKeyToken=8226ea5df37bcae9'
            var dbPath =
                Path.Combine(System.Environment.GetFolderPath
                                 (System.Environment.SpecialFolder.MyDocuments), "..", "Library", "eventsDB.db");

            var eventsRepository       = new EventsRepository(dbPath);
            var organisationRepository = new OrganisationRepository(dbPath);

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App(eventsRepository, organisationRepository));

            return(base.FinishedLaunching(app, options));
        }
Beispiel #26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            var dbPath =
                Path.Combine(System.Environment.GetFolderPath
                                 (System.Environment.SpecialFolder.Personal), "eventsDB.db");

            IEventsRepository       eventsRepository       = new EventsRepository(dbPath);
            IOrganisationRepository organisationRepository = new OrganisationRepository(dbPath);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App(eventsRepository, organisationRepository));
        }
        public void TestDeleteContract()
        {
            OrganisationRepository HelperRepository = new OrganisationRepository(DbContext);

            Organisation organisation = HelperRepository.FindOrganisationById(TestContract.OrganisationId);
            ushort?      previousNumberOfContracts = organisation.NumberOfContracts;

            Repository.DeleteContract(TestContractId);
            Contract savedContract = Repository.FindContractById(TestContractId);

            organisation = HelperRepository.FindOrganisationById(TestContract.OrganisationId);
            ushort?currentNumberOfContracts = organisation.NumberOfContracts;

            Assert.Multiple(() =>
            {
                Assert.Null(savedContract);
                Assert.Less(currentNumberOfContracts, previousNumberOfContracts);
            });
        }
        public void Set_up_and_run_update()
        {
            _organisationStatusId1  = 1;
            _providerTypeId1        = 10;
            _organisationTypeId1    = 100;
            _organisationUkprn      = 11114433;
            _tradingName            = "Trading name 1";
            _tradingNameAfterChange = "Trading Name Version 2";
            _organisationId         = Guid.NewGuid();
            _updateRepository       = 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);
            _organisation = new OrganisationModel
            {
                UKPRN = _organisationUkprn,
                OrganisationTypeId = _organisationTypeId1,
                ProviderTypeId     = _providerTypeId1,
                StatusId           = _organisationStatusId1,
                StatusDate         = DateTime.Today.AddDays(5),
                TradingName        = _tradingName,
                LegalName          = "Legal Name 1",
                Id        = _organisationId,
                CreatedAt = DateTime.Now,
                CreatedBy = "Test"
            };
            OrganisationHandler.InsertRecord(_organisation);
            _originalTradingName = _repository.GetTradingName(_organisationId).Result;
            _changedBy           = "SystemChange";

            _successfulUpdate = _updateRepository.UpdateTradingName(_organisationId, _tradingNameAfterChange, _changedBy).Result;
            _newTradingName   = _repository.GetTradingName(_organisationId).Result;
        }
Beispiel #29
0
        public void Arrange()
        {
            MappingBootstrapper.Initialize();

            var organisationUpdateDomainModel = Builder <Organisation>
                                                .CreateNew()
                                                .With(q => q.PrimaryContact = _primaryContact)
                                                .Build();


            var primaryContactId      = Guid.NewGuid();
            var organisationMockDbSet = CreateOrganisationMockDbSet(primaryContactId);
            var contactsMockDbSet     = CreateContactsMockDbSet(primaryContactId);

            var mockDbContext = CreateMockDbContext(organisationMockDbSet, contactsMockDbSet);

            var organisationRepository = new OrganisationRepository(mockDbContext.Object);

            _result = organisationRepository.UpdateOrganisation(organisationUpdateDomainModel).Result;
        }
Beispiel #30
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);
        }
        public async Task Arrange()
        {
            MappingBootstrapper.Initialize();

            var organisations = new List <Organisation>
            {
                Builder <Organisation> .CreateNew()
                .With(q => q.EndPointAssessorOrganisationId = "123456")
                .With(q => q.Status = OrganisationStatus.Live)
                .With(q => q.EndPointAssessorUkprn = 10000000)
                .Build()
            }.AsQueryable();

            var mockSet = organisations.CreateMockSet(organisations);

            _mockDbContext = CreateMockDbContext(mockSet);

            _organisationRepository = new OrganisationRepository(_mockDbContext.Object);

            await _organisationRepository.Delete("123456");
        }