Esempio n. 1
0
        public override void Modify(OrganisationRecord record)
        {
            DbCommand command = this.Provider.GetStoredProcedure("spInsertUpdateOrganisation");

            this.MapParameterIn(command, "@PA_USER_LOGIN_ID", "dev");
            this.MapParametersIn(command, record, true);
            this.Execute(command);
            this.MapParametersOut(command, record);
        }
        /// <inheritdoc />
        protected override void ParseLine(PafRepository repository, LineIterator iterator)
        {
            var record = new OrganisationRecord();

            record.Key          = GetInt32(iterator, KeyStart, KeyLength);
            record.PostcodeType = ParsePostcodeType(iterator.Buffer[iterator.Offset + PostcodeTypeIndex]);
            record.Name         = GetString(iterator, NameStart, NameLength);
            record.Department   = GetString(iterator, DepartmentStart, DepartmentLength);
            repository.AddOrganisation(record);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public override void AddAddress(AddressRecord record)
        {
            var builder = new StringBuilder(512); // The CSV format of the PAF has a 490 maximum

            OrganisationRecord organisation = GetRelated(record.OrganisationKey, this.organisations);

            if (organisation != null)
            {
                builder.Append(organisation.Name)
                .Append(' ')
                .Append(organisation.Department)
                .Append(' ');
            }

            if (record.BuildingNumber != null)
            {
                builder.Append(record.BuildingNumber)
                .Append(' ');
            }

            builder.Append(GetRelated(record.BuildingNameKey, this.buildingNames))
            .Append(' ')
            .Append(GetRelated(record.SubBuildingNameKey, this.subBuildingNames))
            .Append(' ');

            builder.Append(GetRelated(record.DependentThoroughfareKey, this.thoroughfares))
            .Append(' ')
            .Append(GetRelated(record.DependentThoroughfareDescriptorKey, this.descriptors))
            .Append(' ')
            .Append(GetRelated(record.ThoroughfareKey, this.thoroughfares))
            .Append(' ')
            .Append(GetRelated(record.ThoroughfareDescriptorKey, this.descriptors))
            .Append(' ')
            .Append(record.POBoxNumber)
            .Append(' ');

            LocalityRecord locality = GetRelated(record.LocalityKey, this.localities);

            if (locality != null)
            {
                builder.Append(locality.DoubleDependentLocality)
                .Append(' ')
                .Append(locality.DependentLocality)
                .Append(' ')
                .Append(locality.PostTown);
            }

            this.addresses[record.Key] = builder.ToString();
        }
Esempio n. 4
0
        public async Task Test1()
        {
            // arrange
            var organisation = new OrganisationRecord
            {
                Id    = Guid.NewGuid(),
                Name  = "Organisation 1",
                Users = new List <UserRecord>
                {
                    new UserRecord
                    {
                        Id   = Guid.NewGuid(),
                        Name = "User 1",
                    },
                    new UserRecord
                    {
                        Id   = Guid.NewGuid(),
                        Name = "User 2",
                    },
                },
            };
            var schema = GraphQLSchema.Create(x => new RootQueryType(x));

            // act
            var result = await schema.ExecuteRequestAsync(@"query {
                Organisations {
                    id: Id
                    Name
                    Users {
                        Id
                        Name
                    }
                }
            }", null, null);

            // assert
            Assert.Equal(
                JsonConvert.SerializeObject(new
            {
                id = organisation.Id,
                organisation.Name,
                organisation.Users,
            }),
                JsonConvert.SerializeObject(result)
                );
        }
Esempio n. 5
0
        public async Task Test2()
        {
            // arrange
            var organisation = new OrganisationRecord
            {
                Id    = Guid.NewGuid(),
                Name  = "Organisation 1",
                Users = new List <UserRecord>
                {
                    new UserRecord
                    {
                        Id   = Guid.NewGuid(),
                        Name = "User 1",
                    },
                    new UserRecord
                    {
                        Id   = Guid.NewGuid(),
                        Name = "User 2",
                    },
                },
            };
            var schema = GraphQLSchema.Create(x => new RootQueryType(x));

            // act
            var result = await schema.ExecuteRequestAsync(@"query($values: [String!]!) {
                Values(values: $values)
            }",
                                                          new Dictionary <string, object>
            {
                { "values", new[] { "one", "two" } },
            },
                                                          null);

            // assert
            Assert.Equal(
                JsonConvert.SerializeObject(new
            {
                id = organisation.Id,
                organisation.Name,
                organisation.Users,
            }),
                JsonConvert.SerializeObject(result)
                );
        }
Esempio n. 6
0
 /// <inheritdoc />
 public override void AddOrganisation(OrganisationRecord record)
 {
     this.organisations[record.Key] = record;
 }