public async Task ThenItShouldReturnManagementGroup(LocalAuthority source)
        {
            var actual = await _mapper.MapAsync <ManagementGroup>(source, _cancellationToken);

            Assert.IsNotNull(actual);
            Assert.IsInstanceOf <ManagementGroup>(actual);
        }
コード例 #2
0
        public Location Find(
            StatisticsDbContext context,
            Country country,
            Institution institution       = null,
            LocalAuthority localAuthority = null,
            LocalAuthorityDistrict localAuthorityDistrict         = null,
            LocalEnterprisePartnership localEnterprisePartnership = null,
            MayoralCombinedAuthority mayoralCombinedAuthority     = null,
            Mat multiAcademyTrust           = null,
            OpportunityArea opportunityArea = null,
            ParliamentaryConstituency parliamentaryConstituency = null,
            Region region             = null,
            RscRegion rscRegion       = null,
            Sponsor sponsor           = null,
            Ward ward                 = null,
            PlanningArea planningArea = null)
        {
            var cacheKey = GetCacheKey(country, institution, localAuthority, localAuthorityDistrict,
                                       localEnterprisePartnership, mayoralCombinedAuthority, multiAcademyTrust, opportunityArea,
                                       parliamentaryConstituency, region, rscRegion, sponsor, ward, planningArea);

            if (GetCache().TryGetValue(cacheKey, out Location location))
            {
                return(location);
            }

            location = LookupOrCreate(context, country, institution, localAuthority, localAuthorityDistrict,
                                      localEnterprisePartnership, mayoralCombinedAuthority, multiAcademyTrust, opportunityArea,
                                      parliamentaryConstituency, region, rscRegion, sponsor, ward, planningArea);
            GetCache().Set(cacheKey, location);

            return(location);
        }
コード例 #3
0
        public async Task ThenItShouldReturnManagementGroupWhenMappingLocalAuthorityToManagementGroup(
            LocalAuthority source)
        {
            var actual = await _mapper.MapAsync <ManagementGroup>(source, new CancellationToken());

            Assert.IsInstanceOf <ManagementGroup>(actual);
        }
コード例 #4
0
        public async Task ProcessGetAuthorityForInvalidItemsThrowsMalformedRequest()
        {
            // arrange
            const string theAdminDistrict = "E1234567";
            const string theTouchpoint    = "00000000112";
            var          localAuthority   = new LocalAuthority
            {
                TouchpointID = "any old touchpoint",
                LADCode      = null
            };

            var sut = MakeSUT();

            var scope = MakeStrictMock <IScopeLoggingContext>();

            GetMock(scope)
            .Setup(x => x.EnterMethod("ProcessGetAuthorityFor"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"seeking the admin district: '{theAdminDistrict}'"))
            .Returns(Task.CompletedTask);
            GetMock(sut.Authorities)
            .Setup(x => x.Get(theAdminDistrict))
            .Returns(Task.FromResult <ILocalAuthority>(localAuthority));

            // act / assert
            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.ProcessGetAuthorityFor(theTouchpoint, theAdminDistrict, scope));
        }
コード例 #5
0
        private static string GetCacheKey(Country country,
                                          Institution institution,
                                          LocalAuthority localAuthority,
                                          LocalAuthorityDistrict localAuthorityDistrict,
                                          LocalEnterprisePartnership localEnterprisePartnership,
                                          MayoralCombinedAuthority mayoralCombinedAuthority,
                                          Mat multiAcademyTrust,
                                          OpportunityArea opportunityArea,
                                          ParliamentaryConstituency parliamentaryConstituency,
                                          Region region,
                                          RscRegion rscRegion,
                                          Sponsor sponsor,
                                          Ward ward,
                                          PlanningArea planningArea)
        {
            var observationalUnits = new IObservationalUnit[]
            {
                country, institution, localAuthority, localAuthorityDistrict, localEnterprisePartnership,
                mayoralCombinedAuthority, multiAcademyTrust, parliamentaryConstituency, opportunityArea, region,
                rscRegion, sponsor, ward, planningArea
            };

            const string separator = "_";

            return(string.Join(separator, observationalUnits
                               .Where(unit => unit != null)
                               .Select(unit => $"{unit.GetType()}:{(unit is LocalAuthority la ? la.GetCodeOrOldCodeIfEmpty() : unit.Code )}:{unit.Name}")));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(int id, LocalAuthorityViewModel viewModel)
        {
            if (id != viewModel.LocalAuthorityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    LocalAuthority model = new LocalAuthority();
                    _mapper.Map(viewModel, model);

                    _context.Update(model);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocalAuthorityExists(viewModel.LocalAuthorityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(viewModel));
        }
コード例 #7
0
        public async Task ProcessDeleteAuthorityForUsingMissMatchedParametersThrows()
        {
            // arrange
            const string theAdminDistrict = "E1234567";
            const string theTouchpoint    = "00000000112";
            var          localAuthority   = new LocalAuthority
            {
                TouchpointID = "any old touchpoint",
                LADCode      = null
            };

            var sut = MakeSUT();

            var scope = MakeStrictMock <IScopeLoggingContext>();

            GetMock(scope)
            .Setup(x => x.EnterMethod("ProcessDeleteAuthorityFor"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"seeking the admin district: '{theAdminDistrict}'"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"candidate search complete: ''"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"validating touchpoint integrity: '{localAuthority.TouchpointID}' == '{theTouchpoint}'"))
            .Returns(Task.CompletedTask);

            GetMock(sut.Authorities)
            .Setup(x => x.Get(theAdminDistrict))
            .Returns(Task.FromResult <ILocalAuthority>(localAuthority));

            // act / assert
            await Assert.ThrowsAsync <NoContentException>(() => sut.ProcessDeleteAuthorityFor(theTouchpoint, theAdminDistrict, scope));
        }
コード例 #8
0
        private Location LookupOrCreate(
            StatisticsDbContext context,
            Country country,
            Institution institution       = null,
            LocalAuthority localAuthority = null,
            LocalAuthorityDistrict localAuthorityDistrict         = null,
            LocalEnterprisePartnership localEnterprisePartnership = null,
            MayoralCombinedAuthority mayoralCombinedAuthority     = null,
            Mat multiAcademyTrust           = null,
            OpportunityArea opportunityArea = null,
            ParliamentaryConstituency parliamentaryConstituency = null,
            Region region             = null,
            RscRegion rscRegion       = null,
            Sponsor sponsor           = null,
            Ward ward                 = null,
            PlanningArea planningArea = null)
        {
            var location = Lookup(
                context,
                country,
                institution,
                localAuthority,
                localAuthorityDistrict,
                localEnterprisePartnership,
                mayoralCombinedAuthority,
                multiAcademyTrust,
                opportunityArea,
                parliamentaryConstituency,
                region,
                rscRegion,
                sponsor,
                ward,
                planningArea);

            if (location == null)
            {
                var entityEntry = context.Location.Add(new Location
                {
                    Id                         = _guidGenerator.NewGuid(),
                    Country                    = country ?? Country.Empty(),
                    Institution                = institution ?? Institution.Empty(),
                    LocalAuthority             = localAuthority ?? LocalAuthority.Empty(),
                    LocalAuthorityDistrict     = localAuthorityDistrict ?? LocalAuthorityDistrict.Empty(),
                    LocalEnterprisePartnership = localEnterprisePartnership ?? LocalEnterprisePartnership.Empty(),
                    MayoralCombinedAuthority   = mayoralCombinedAuthority ?? MayoralCombinedAuthority.Empty(),
                    MultiAcademyTrust          = multiAcademyTrust ?? Mat.Empty(),
                    OpportunityArea            = opportunityArea ?? OpportunityArea.Empty(),
                    ParliamentaryConstituency  = parliamentaryConstituency ?? ParliamentaryConstituency.Empty(),
                    Region                     = region ?? Region.Empty(),
                    RscRegion                  = rscRegion ?? RscRegion.Empty(),
                    Sponsor                    = sponsor ?? Sponsor.Empty(),
                    Ward                       = ward ?? Ward.Empty(),
                    PlanningArea               = planningArea ?? PlanningArea.Empty()
                });

                return(entityEntry.Entity);
            }

            return(location);
        }
        public async Task StoreLocalAuthorityAsync(LocalAuthority localAuthority, DateTime date, CancellationToken cancellationToken)
        {
            var json     = JsonConvert.SerializeObject(localAuthority);
            var fileName = $"localauthority-{localAuthority.Code}-{date:yyyyMMdd}.json";
            var path     = Path.Combine(_dataDirectory, fileName);

            await FileHelper.WriteStringToFileAsync(path, json);

            _localAuthorityIndex.AddDateToIndex(localAuthority.Code, date);
        }
コード例 #10
0
        public async Task ProcessGetAuthorityForValidItemsMeetsVerification()
        {
            // arrange
            const string theAdminDistrict = "E1234567";
            const string theTouchpoint    = "00000000112";
            var          localAuthority   = new LocalAuthority
            {
                TouchpointID = theTouchpoint,
                LADCode      = theAdminDistrict
            };

            var sut = MakeSUT();

            GetMock(sut.Authorities)
            .Setup(x => x.Get(theAdminDistrict))
            .Returns(Task.FromResult <ILocalAuthority>(localAuthority));

            GetMock(sut.Respond)
            .Setup(x => x.Ok())
            .Returns(new HttpResponseMessage());

            var scope = MakeStrictMock <IScopeLoggingContext>();

            GetMock(scope)
            .Setup(x => x.EnterMethod("ProcessGetAuthorityFor"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"seeking the admin district: '{theAdminDistrict}'"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"candidate search complete: '{theAdminDistrict}'"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"validating touchpoint integrity: '{localAuthority.TouchpointID}' == '{theTouchpoint}'"))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"preparing response..."))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.Information($"preparation complete..."))
            .Returns(Task.CompletedTask);
            GetMock(scope)
            .Setup(x => x.ExitMethod("ProcessGetAuthorityFor"))
            .Returns(Task.CompletedTask);

            // act
            var result = await sut.ProcessGetAuthorityFor(theTouchpoint, theAdminDistrict, scope);

            // assert
            Assert.IsAssignableFrom <HttpResponseMessage>(result);
            GetMock(sut.Authorities).VerifyAll();
            GetMock(sut.Respond).VerifyAll();
            GetMock(sut.Faults).VerifyAll();
            GetMock(sut.SafeOperations).VerifyAll();
        }
        public async Task ThenItShouldMapCodeFromTranslatedTypeAndIdentifier(LocalAuthority source, string transformedType)
        {
            _translatorMock.Setup(t =>
                                  t.TranslateEnumValue(EnumerationNames.ManagementGroupType, It.IsAny <string>(),
                                                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(transformedType);

            var actual = await _mapper.MapAsync <ManagementGroup>(source, _cancellationToken);

            Assert.IsNotNull(actual);
            Assert.AreEqual($"{transformedType}-{source.Code}", actual.Code);
        }
        public async Task ThenItShouldMapTypeFromTranslation(LocalAuthority source, string transformedValue)
        {
            _translatorMock.Setup(t =>
                                  t.TranslateEnumValue(EnumerationNames.ManagementGroupType, It.IsAny <string>(),
                                                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(transformedValue);

            var actual = await _mapper.MapAsync <ManagementGroup>(source, _cancellationToken);

            Assert.IsNotNull(actual);
            Assert.AreEqual(transformedValue, actual.Type);
            _translatorMock.Verify(
                t => t.TranslateEnumValue(EnumerationNames.ManagementGroupType, LocalAuthority.ManagementGroupType,
                                          _cancellationToken),
                Times.Once);
        }
コード例 #13
0
        public void MakeDocumentPathForKeyValueAndCollectionMeetsExpectation(string keyValue, string collectionPath)
        {
            // arrange
            var document = new LocalAuthority {
                LADCode = keyValue
            };
            var collectionUri = new Uri(collectionPath, UriKind.Relative);
            var documentPath  = $"{collectionPath}/docs/{keyValue}";

            var sut = MakeSUT();

            // act
            var result = sut.MakeDocumentPathFor(document, collectionUri);

            // assert
            Assert.Equal(documentPath, result.OriginalString);
        }
コード例 #14
0
        public async Task <IActionResult> Create(LocalAuthorityViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                LocalAuthority model = new LocalAuthority();
                _mapper.Map(viewModel, model);

                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            PopulateDropDowns(viewModel);

            return(View(viewModel));
        }
コード例 #15
0
        public async Task DeleteDocumentAsyncWithValidURIMeetsVerification()
        {
            // arrange
            var sut         = MakeSUT();
            var documentUri = new Uri("dbs/areas/colls/routing/docs/0000123", UriKind.Relative);
            var document    = new LocalAuthority();

            GetMock(sut.Client)
            .Setup(x => x.DeleteDocumentAsync(documentUri, It.IsAny <RequestOptions>(), default))
            .Returns(Task.FromResult(new ResourceResponse <Document>()));

            // act
            await sut.DeleteDocumentAsync(documentUri, string.Empty);

            // assert
            GetMock(sut.Client).VerifyAll();
        }
コード例 #16
0
        public async Task ReadDocumentAsyncWithValidURIMeetsExpectation()
        {
            // arrange
            var sut         = MakeSUT();
            var documentUri = new Uri("dbs/areas/colls/routing/docs/0000123", UriKind.Relative);
            var document    = new LocalAuthority();

            GetMock(sut.Client)
            .Setup(x => x.ReadDocumentAsync <LocalAuthority>(documentUri, It.IsAny <RequestOptions>(), default))
            .Returns(Task.FromResult(new DocumentResponse <LocalAuthority>(document)));

            // act
            var result = await sut.ReadDocumentAsync <LocalAuthority>(documentUri, string.Empty);

            // assert
            Assert.IsAssignableFrom <ILocalAuthority>(result);
        }
コード例 #17
0
        public async Task AddDocumentMeetsVerification()
        {
            // arrange
            var sut       = MakeSUT();
            var modelItem = new LocalAuthority();
            var testPath  = new Uri("http://blahStore/blahCollection/blahID");

            GetMock(sut.SafeOperations)
            .Setup(x => x.Try(It.IsAny <Func <Task <LocalAuthority> > >(), It.IsAny <Func <Exception, Task <LocalAuthority> > >()))
            .Returns(Task.FromResult(modelItem));

            // act
            await sut.AddDocument(modelItem, testPath);

            // assert
            GetMock(sut.Client).VerifyAll();
            GetMock(sut.SafeOperations).VerifyAll();
        }
コード例 #18
0
        private async Task <LinkedEntity> MapToEntityAsync(LocalAuthority localAuthority, CancellationToken cancellationToken)
        {
            var translatedGroupType = await _translation.TranslateEnumValueAsync(
                EnumerationNames.ManagementGroupType, SourceSystemNames.GetInformationAboutSchools, LocalAuthority.ManagementGroupType, cancellationToken);

            var code = $"{translatedGroupType}-{localAuthority.Code}";

            return(new LinkedEntity
            {
                EntityType = EntityTypeManagementGroup,
                SourceSystemName = SourceSystemNames.GetInformationAboutSchools,
                SourceSystemId = code,
                Name = localAuthority.Name,
                ManagementGroupType = translatedGroupType,
                ManagementGroupCode = code,
                ManagementGroupId = localAuthority.Code.ToString(),
            });
        }
コード例 #19
0
        public async Task ProcessAddDocumentMeetsVerification()
        {
            // arrange
            var sut       = MakeSUT();
            var modelItem = new LocalAuthority();
            var testPath  = new Uri("http://blahStore/blahCollection/blahID");

            GetMock(sut.Client)
            .Setup(x => x.CreateDocumentAsync(testPath, modelItem))
            .Returns(Task.FromResult(modelItem));

            // act
            await sut.ProcessAddDocument(testPath, modelItem);

            // assert
            GetMock(sut.Client).VerifyAll();
            GetMock(sut.SafeOperations).VerifyAll();
        }
コード例 #20
0
 private void OnMouseDown()
 {
     if (LocalAuthority.IsAlive && IsAlive)
     {
         if (LocalAuthority.SelectedAbility != null && LocalAuthority.IsValidTarget(this))
         {
             LocalAuthority.OnAbilityTargetChosen(this);
         }
         else if (LocalAuthority.attacksRemaining > 0)
         {
             Stat[] stats = { Stat.Burn, Stat.Freeze };
             foreach (Stat stat in stats)
             {
                 if (HasStatusEffect(stat))
                 {
                     LocalAuthority.CmdHelpWithStat(stat, gameObject);
                     break;
                 }
             }
         }
     }
 }
        public async Task ThenItShouldMapGroupToManagementGroupForBasicTypeProperties(LocalAuthority source)
        {
            var actual = await _mapper.MapAsync <ManagementGroup>(source, _cancellationToken);

            Assert.IsNotNull(actual);
            Assert.AreEqual(source.Name, actual.Name);
            Assert.AreEqual(source.Code.ToString(), actual.Identifier);
        }
コード例 #22
0
        public static void Initialize(ApplicationDbContext context)
        {
            //context.Database.EnsureCreated();

            //Look for any Genders
            if (context.Gender.Any())
            {
                return; //DB has been seeded{
            }


            var regions = new Region[]
            {
                new Region {
                    RegionName = "South", RegionRegionalManagerId = 1
                },
                new Region {
                    RegionName = "Oxfordshire", RegionRegionalManagerId = 2
                },
                new Region {
                    RegionName = "West Berkshire", RegionRegionalManagerId = 3
                },
                new Region {
                    RegionName = "East Midlands", RegionRegionalManagerId = 4
                },
                new Region {
                    RegionName = "West Midlands", RegionRegionalManagerId = 1
                },
                new Region {
                    RegionName = "LONDON", RegionRegionalManagerId = 2
                },
                new Region {
                    RegionName = "SOUTH EAST", RegionRegionalManagerId = 2
                },
                new Region {
                    RegionName = "SOUTH WEST", RegionRegionalManagerId = 2
                },
                new Region {
                    RegionName = "WALES", RegionRegionalManagerId = 2
                },
                new Region {
                    RegionName = "OTHER", RegionRegionalManagerId = 2
                }
            };

            foreach (Region g in regions)
            {
                context.Region.Add(g);
            }
            context.SaveChanges();


            var leavingReasons = new LeavingReason[]
            {
                new LeavingReason {
                    LeavingReasonName = "Increased level of risk"
                },
                new LeavingReason {
                    LeavingReasonName = "Returned home"
                },
                new LeavingReason {
                    LeavingReasonName = "Transition to foster care"
                },
                new LeavingReason {
                    LeavingReasonName = "Age-related leaver"
                },
                new LeavingReason {
                    LeavingReasonName = "Geography"
                },
                new LeavingReason {
                    LeavingReasonName = "Internal Transfer within group"
                },
                new LeavingReason {
                    LeavingReasonName = "LA Decision"
                },
                new LeavingReason {
                    LeavingReasonName = "Other"
                }
            };

            foreach (LeavingReason g in leavingReasons)
            {
                context.LeavingReason.Add(g);
            }
            context.SaveChanges();



            var regionalManager = new RegionalManager[]
            {
                new RegionalManager {
                    RegionalManagerName = "Rodrigo Ferreira"
                },
                new RegionalManager {
                    RegionalManagerName = "James Cliff"
                },
                new RegionalManager {
                    RegionalManagerName = "Jarrod Elcock"
                },
                new RegionalManager {
                    RegionalManagerName = "Sam Millward"
                },
            };

            foreach (RegionalManager r in regionalManager)
            {
                context.RegionalManager.Add(r);
            }
            context.SaveChanges();

            var genders = new Gender[]
            {                //new Gender{GenderName="---enter gender---"},
                new Gender {
                    GenderName = "Male"
                },
                new Gender {
                    GenderName = "Female"
                },
                new Gender {
                    GenderName = "Transgender"
                },
                new Gender {
                    GenderName = "Other"
                }
            };

            foreach (Gender g in genders)
            {
                context.Gender.Add(g);
            }
            context.SaveChanges();


            var localauthorities = new LocalAuthority[]
            {
                new LocalAuthority {
                    LocalAuthorityName = "Barking and Dagenham", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Barnet", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Barnsley", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bath and North East Somerset ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bedford ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Berkshire", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bexley", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Birmingham", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Blackburn with Darwen ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Blackpool ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Blaenau Gwent", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bolton", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bournemouth ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bracknell Forest ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bradford", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Brent", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bridgend ", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Brighton and Hove ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bristol City", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bromley", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Buckinghamshire ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Burnley", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Bury", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Caerphilly", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cafcass", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Calderdale", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cambridgeshire ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Camden", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cardiff", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Carmarthenshire", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Central Bedfordshire ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Ceredigion", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cheshire East ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cheshire West and Chester ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "City of London", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cleveland - Redcar", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Conwy", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cornwall ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Coventry", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Croydon", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Cumbria ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Darlington", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Denbighshire", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Derby ", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Derbyshire ", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Devon ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Doncaster", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Dorset ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Dudley ", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Dumfries", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Durham", LocalAuthorityRegionId = 10
                },
                new LocalAuthority {
                    LocalAuthorityName = "Ealing", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "East Midlands", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "East Riding of Yorkshire ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "East Sussex ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Enfield", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Essex ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Flintshire", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Gateshead", LocalAuthorityRegionId = 10
                },
                new LocalAuthority {
                    LocalAuthorityName = "Glamorgan", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Gloucestershire ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Greenwich", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Guernsey", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Gwent", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Gwynedd", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hackney", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Halton ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hammersmith and Fulham", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hampshire ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Haringey", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Harlow", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Harrow", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hartlepool", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Havering", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Herefordshire", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hertfordshire", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hillingdon", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hounslow", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Huddersfield", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Hull City", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "International", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Isle of Anglesey", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Isle of Man", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Isle of Wight ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Isles of Scilly ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Islington", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Jersey", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Kensington and Chelsea", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Kent ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Kingston upon Thames", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Kirklees", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Knowsley ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Lambeth", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Lancashire ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Leeds", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Leicester ", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Leicestershire", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Lewisham", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Lincolnshire", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Liverpool", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Living Autism", LocalAuthorityRegionId = 10
                },
                new LocalAuthority {
                    LocalAuthorityName = "Luton ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Manchester", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Medway ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Merthyr Tydfil", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Merton", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Middlesborough", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Milton Keynes ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Monmouthshire", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Neath Port Talbot", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Newcastle City Council", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Newham", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Newport", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Norfolk", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "North East Lincolnshire ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "North Lincolnshire ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "North Somerset ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "North Tyneside", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "North Yorkshire ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Northamptonshire", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Northern Ireland", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Northumberland", LocalAuthorityRegionId = 10
                },
                new LocalAuthority {
                    LocalAuthorityName = "Nottingham City", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Nottinghamshire ", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Oldham ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Oxford & Central", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Oxfordshire", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Pembrokeshire", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Pengower", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Peterborough ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Plymouth ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Poole ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Portsmouth ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Powys", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Reading ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Redbridge", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Rhondda Cynon Taf", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Richmond upon Thames", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Rochdale", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Rotherham ", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Rutland ", LocalAuthorityRegionId = 3
                },
                new LocalAuthority {
                    LocalAuthorityName = "Salford", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sandwell ", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Scarborough", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Scotland", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sefton", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sheffield", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Shropshire ", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Slough ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Solihull", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Somerset", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "South Gloucestershire ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "South Tyneside", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "South West London", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Southampton", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Southend", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Southend-on-Sea ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Southern Region", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Southwark", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "St. Helens", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Staffordshire", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Stevenage", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Stockport", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Stockton", LocalAuthorityRegionId = 10
                },
                new LocalAuthority {
                    LocalAuthorityName = "Stoke-on-Trent", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Suffolk", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sunderland", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Surrey", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sutton", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Sutton Coldfield", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Swansea", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Swindon ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Tameside", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Telford and Wrekin ", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "The Vale of Glamorgan", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Thurrock ", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "Torbay ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Torfaen", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "Tower Hamlets", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Trafford", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Unknown", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wakefield", LocalAuthorityRegionId = 2
                },
                new LocalAuthority {
                    LocalAuthorityName = "Walsall", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Waltham Forest", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wandsworth", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Warrington ", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Warwickshire", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "West Berkshire ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "West Midlands", LocalAuthorityRegionId = 5
                },
                new LocalAuthority {
                    LocalAuthorityName = "West Sussex", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Westminster", LocalAuthorityRegionId = 6
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wigan", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wiltshire ", LocalAuthorityRegionId = 8
                },
                new LocalAuthority {
                    LocalAuthorityName = "Windsor and Maidenhead ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wirral", LocalAuthorityRegionId = 1
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wokingham ", LocalAuthorityRegionId = 7
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wolverhampton", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Worcestershire ", LocalAuthorityRegionId = 4
                },
                new LocalAuthority {
                    LocalAuthorityName = "Wrexham", LocalAuthorityRegionId = 9
                },
                new LocalAuthority {
                    LocalAuthorityName = "York City", LocalAuthorityRegionId = 2
                }
            };

            foreach (LocalAuthority la in localauthorities)
            {
                context.LocalAuthority.Add(la);
            }
            context.SaveChanges();

            var refstatus = new Status[]
            {
                new Status {
                    StatusName = "Placed", StatusPriority = 1
                },
                new Status {
                    StatusName = "Archive", StatusPriority = 2
                },
                new Status {
                    StatusName = "Confirmed pending start date", StatusPriority = 3
                },
                new Status {
                    StatusName = "Offered", StatusPriority = 4
                },
                new Status {
                    StatusName = "In Correspondence with LA", StatusPriority = 5
                },
                new Status {
                    StatusName = "Assessment/Visit Stage", StatusPriority = 6
                },
                new Status {
                    StatusName = "In correspondence with family", StatusPriority = 7
                },
                new Status {
                    StatusName = "Under Consideration by Service", StatusPriority = 8
                }
            };

            foreach (Status r in refstatus)
            {
                context.Status.Add(r);
            }
            context.SaveChanges();



            var serv = new Service[]
            {
                new Service {
                    ServiceName = "Acorn Cottage", ServiceRegionId = 1, ServicePlaces = 10
                },
                new Service {
                    ServiceName = "Aqueduct House", ServiceRegionId = 2, ServicePlaces = 20
                },
                new Service {
                    ServiceName = "Ash House", ServiceRegionId = 3, ServicePlaces = 12
                },
                new Service {
                    ServiceName = "Ashley", ServiceRegionId = 4, ServicePlaces = 11
                },
                new Service {
                    ServiceName = "Barnfield Lodge", ServiceRegionId = 1, ServicePlaces = 15
                },
                new Service {
                    ServiceName = "The Bartons", ServiceRegionId = 2, ServicePlaces = 16
                },
                new Service {
                    ServiceName = "Beachlands", ServiceRegionId = 3, ServicePlaces = 12
                },
                new Service {
                    ServiceName = "The Birches", ServiceRegionId = 4, ServicePlaces = 15
                },
                new Service {
                    ServiceName = "Denmead", ServiceRegionId = 1, ServicePlaces = 12
                },
                new Service {
                    ServiceName = "Eyton House", ServiceRegionId = 2, ServicePlaces = 19
                },
                new Service {
                    ServiceName = "Haven Lodge", ServiceRegionId = 3, ServicePlaces = 18
                },
                new Service {
                    ServiceName = "Hayling Island", ServiceRegionId = 4, ServicePlaces = 17
                },
                new Service {
                    ServiceName = "The Laurels", ServiceRegionId = 1, ServicePlaces = 16
                },
                new Service {
                    ServiceName = "The Meadows", ServiceRegionId = 2, ServicePlaces = 15
                },
                new Service {
                    ServiceName = "The Moorlands", ServiceRegionId = 3, ServicePlaces = 14
                },
                new Service {
                    ServiceName = "Newlands", ServiceRegionId = 4, ServicePlaces = 13
                },
                new Service {
                    ServiceName = "Oathill Loadge", ServiceRegionId = 1, ServicePlaces = 12
                },
                new Service {
                    ServiceName = "The Paddocks", ServiceRegionId = 2, ServicePlaces = 11
                },
                new Service {
                    ServiceName = "Park Farm", ServiceRegionId = 3, ServicePlaces = 10
                },
                new Service {
                    ServiceName = "Poppy Lodge", ServiceRegionId = 4, ServicePlaces = 9
                },
                new Service {
                    ServiceName = "Spinney House", ServiceRegionId = 1, ServicePlaces = 10
                },
                new Service {
                    ServiceName = "Steps", ServiceRegionId = 2, ServicePlaces = 11
                },
                new Service {
                    ServiceName = "Sunnycroft", ServiceRegionId = 3, ServicePlaces = 30
                },
                new Service {
                    ServiceName = "Villa Farm House", ServiceRegionId = 4, ServicePlaces = 40
                },
                new Service {
                    ServiceName = "Weaveley", ServiceRegionId = 1, ServicePlaces = 13
                },
                new Service {
                    ServiceName = "Ramsworth Cottage", ServiceRegionId = 2, ServicePlaces = 25
                },
                new Service {
                    ServiceName = "Jubilee School", ServiceRegionId = 3, ServicePlaces = 28
                },
                new Service {
                    ServiceName = "New Barn School", ServiceRegionId = 4, ServicePlaces = 15
                },
                new Service {
                    ServiceName = "Manor House School", ServiceRegionId = 1, ServicePlaces = 16
                },
                new Service {
                    ServiceName = "Shifnal School", ServiceRegionId = 2, ServicePlaces = 18
                },
                new Service {
                    ServiceName = "Park School", ServiceRegionId = 3, ServicePlaces = 20
                },
            };

            foreach (Service r in serv)
            {
                context.Service.Add(r);
            }
            context.SaveChanges();



            var arcreason = new ArchiveReason[]
            {
                new ArchiveReason {
                    ArchiveReasonName = "Too high risk", ArchiveDecisionBy = 1
                },
                new ArchiveReason {
                    ArchiveReasonName = "Unable to meet the timescales", ArchiveDecisionBy = 2
                },
                new ArchiveReason {
                    ArchiveReasonName = "Not Compatible", ArchiveDecisionBy = 3
                },
                new ArchiveReason {
                    ArchiveReasonName = "Placed Elsewhere", ArchiveDecisionBy = 4
                },
                new ArchiveReason {
                    ArchiveReasonName = "Family Preference", ArchiveDecisionBy = 4
                },
                new ArchiveReason {
                    ArchiveReasonName = "Cost", ArchiveDecisionBy = 4
                },
                new ArchiveReason {
                    ArchiveReasonName = "OFSTED rating", ArchiveDecisionBy = 4
                },
                new ArchiveReason {
                    ArchiveReasonName = "Wrong Location - LA decison", ArchiveDecisionBy = 4
                },
                new ArchiveReason {
                    ArchiveReasonName = "Wrong Location - Our decision", ArchiveDecisionBy = 3
                },
                new ArchiveReason {
                    ArchiveReasonName = "Referral withdrawn", ArchiveDecisionBy = 1
                },
                new ArchiveReason {
                    ArchiveReasonName = "No reason given", ArchiveDecisionBy = 2
                },
                new ArchiveReason {
                    ArchiveReasonName = "Unsuitable following assessment", ArchiveDecisionBy = 1
                },
                new ArchiveReason {
                    ArchiveReasonName = "Timescales", ArchiveDecisionBy = 2
                },
                new ArchiveReason {
                    ArchiveReasonName = "Insufficient resources at this time", ArchiveDecisionBy = 3
                },
                new ArchiveReason {
                    ArchiveReasonName = "Other", ArchiveDecisionBy = 4
                }
            };

            foreach (ArchiveReason a in arcreason)
            {
                context.ArchiveReason.Add(a);
            }
            context.SaveChanges();
        }
コード例 #23
0
        private Location Lookup(
            StatisticsDbContext context,
            Country country,
            Institution institution       = null,
            LocalAuthority localAuthority = null,
            LocalAuthorityDistrict localAuthorityDistrict         = null,
            LocalEnterprisePartnership localEnterprisePartnership = null,
            MayoralCombinedAuthority mayoralCombinedAuthority     = null,
            Mat multiAcademyTrust           = null,
            OpportunityArea opportunityArea = null,
            ParliamentaryConstituency parliamentaryConstituency = null,
            Region region             = null,
            RscRegion rscRegion       = null,
            Sponsor sponsor           = null,
            Ward ward                 = null,
            PlanningArea planningArea = null)
        {
            var predicateBuilder = PredicateBuilder.True <Location>()
                                   .And(location => location.Country.Code == country.Code && location.Country.Name == country.Name);

            predicateBuilder = predicateBuilder
                               .And(location => location.Institution.Code == (institution != null ? institution.Code : null) &&
                                    location.Institution.Name == (institution != null ? institution.Name : null));

            // Also match the old LA code even if blank
            predicateBuilder = predicateBuilder
                               .And(location =>
                                    location.LocalAuthority.Code == (localAuthority != null && localAuthority.Code != null ? localAuthority.Code : null) &&
                                    location.LocalAuthority.OldCode == (localAuthority != null && localAuthority.OldCode != null ? localAuthority.OldCode : null) &&
                                    location.LocalAuthority.Name == (localAuthority != null ? localAuthority.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.LocalAuthorityDistrict.Code == (localAuthorityDistrict != null ? localAuthorityDistrict.Code : null) &&
                                    location.LocalAuthorityDistrict.Name == (localAuthorityDistrict != null ? localAuthorityDistrict.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.LocalEnterprisePartnership.Code == (localEnterprisePartnership != null ? localEnterprisePartnership.Code : null) &&
                                    location.LocalEnterprisePartnership.Name == (localEnterprisePartnership != null ? localEnterprisePartnership.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.MayoralCombinedAuthority.Code == (mayoralCombinedAuthority != null ? mayoralCombinedAuthority.Code : null) &&
                                    location.MayoralCombinedAuthority.Name == (mayoralCombinedAuthority != null ? mayoralCombinedAuthority.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.MultiAcademyTrust.Code == (multiAcademyTrust != null ? multiAcademyTrust.Code : null) &&
                                    location.MultiAcademyTrust.Name == (multiAcademyTrust != null ? multiAcademyTrust.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.OpportunityArea.Code == (opportunityArea != null ? opportunityArea.Code : null) &&
                                    location.OpportunityArea.Name == (opportunityArea != null ? opportunityArea.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.ParliamentaryConstituency.Code == (parliamentaryConstituency != null ? parliamentaryConstituency.Code : null) &&
                                    location.ParliamentaryConstituency.Name == (parliamentaryConstituency != null ? parliamentaryConstituency.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.Region.Code == (region != null ? region.Code : null) &&
                                    location.Region.Name == (region != null ? region.Name : null));

            // Note that Name is not included in the predicate here as it is the same as the code
            predicateBuilder = predicateBuilder
                               .And(location => location.RscRegion.Code == (rscRegion != null ? rscRegion.Code : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.Sponsor.Code == (sponsor != null ? sponsor.Code : null) &&
                                    location.Sponsor.Name == (sponsor != null ? sponsor.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.Ward.Code == (ward != null ? ward.Code : null) &&
                                    location.Ward.Name == (ward != null ? ward.Name : null));

            predicateBuilder = predicateBuilder
                               .And(location => location.PlanningArea.Code == (planningArea != null ? planningArea.Code : null) &&
                                    location.PlanningArea.Name == (planningArea != null ? planningArea.Name : null));

            return(context.Location.AsNoTracking().FirstOrDefault(predicateBuilder));
        }
コード例 #24
0
 private bool AreSame(LocalAuthority current, LocalAuthority staging)
 {
     return(current.Name == staging.Name);
 }
コード例 #25
0
 public LocalAuthorityModel(LocalAuthority model) : base(model)
 {
     LeaCode = model.LeaCode;
     Name    = model.Name;
     Website = model.Website;
 }