Ejemplo n.º 1
0
        public static async Task <SiteVariableAmountsFact> Load(WaDEContext db, SiteVariableAmountsFactBuilderOptions opts)
        {
            opts.OrganizationsDim = opts.OrganizationsDim ?? await OrganizationsDimBuilder.Load(db);

            opts.SiteDim = opts.SiteDim ?? await SitesDimBuilder.Load(db);

            opts.VariablesDim = opts.VariablesDim ?? await VariablesDimBuilder.Load(db);

            opts.WaterSourcesDim = opts.WaterSourcesDim ?? await WaterSourcesDimBuilder.Load(db);

            opts.MethodsDim = opts.MethodsDim ?? await MethodsDimBuilder.Load(db);

            opts.TimeframeStart = opts.TimeframeStart ?? await DateDimBuilder.Load(db);

            opts.TimeframeEnd = opts.TimeframeEnd ?? await DateDimBuilder.Load(db);

            opts.DataPublicationDate = opts.DataPublicationDate ?? await DateDimBuilder.Load(db);

            var item = Create(opts);

            db.SiteVariableAmountsFact.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Ejemplo n.º 2
0
        public static async Task <AggregatedAmountsFact> Load(WaDEContext db, AggregatedAmountsFactBuilderOptions opts)
        {
            opts.OrganizationsDim = opts.OrganizationsDim ?? await OrganizationsDimBuilder.Load(db);

            opts.ReportingUnitsDim = opts.ReportingUnitsDim ?? await ReportingUnitsDimBuilder.Load(db);

            opts.VariablesDim = opts.VariablesDim ?? await VariablesDimBuilder.Load(db);

            opts.WaterSourcesDim = opts.WaterSourcesDim ?? await WaterSourcesDimBuilder.Load(db);

            opts.MethodsDim = opts.MethodsDim ?? await MethodsDimBuilder.Load(db);

            var item = Create(opts);

            db.AggregatedAmountsFact.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Ejemplo n.º 3
0
        public static async Task <AllocationAmountsFact> Load(WaDEContext db, AllocationAmountsFactBuilderOptions opts)
        {
            opts.OrganizationsDim = opts.OrganizationsDim ?? await OrganizationsDimBuilder.Load(db);

            opts.VariablesDim = opts.VariablesDim ?? await VariablesDimBuilder.Load(db);

            opts.WaterSourcesDim = opts.WaterSourcesDim ?? await WaterSourcesDimBuilder.Load(db);

            opts.MethodsDim = opts.MethodsDim ?? await MethodsDimBuilder.Load(db);

            opts.DataPublicationDate = opts.DataPublicationDate ?? await DateDimBuilder.Load(db);

            opts.AllocationPriorityDate = opts.AllocationPriorityDate ?? await DateDimBuilder.Load(db);

            var item = Create(opts);

            db.AllocationAmountsFact.Add(item);
            await db.SaveChangesAsync();

            return(item);
        }
Ejemplo n.º 4
0
        public static AllocationAmountsFact Create(AllocationAmountsFactBuilderOptions opts)
        {
            var faker = new Faker <AllocationAmountsFact>()
                        .RuleFor(a => a.OrganizationId, f => opts.OrganizationsDim?.OrganizationId ?? OrganizationsDimBuilder.GenerateId())
                        .RuleFor(a => a.VariableSpecificId, f => opts.VariablesDim?.VariableSpecificId ?? VariablesDimBuilder.GenerateId())
                        .RuleFor(a => a.WaterSourceId, f => opts.WaterSourcesDim?.WaterSourceId ?? WaterSourcesDimBuilder.GenerateId())
                        .RuleFor(a => a.MethodId, f => opts.MethodsDim?.MethodId ?? MethodsDimBuilder.GenerateId())
                        .RuleFor(a => a.PrimaryUseCategoryCV, f => opts.PrimaryBeneficialUsesCv?.Name)
                        .RuleFor(a => a.DataPublicationDateId, f => opts.DataPublicationDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Words(3))
                        .RuleFor(a => a.AllocationNativeId, f => f.Random.Uuid().ToString())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Word())
                        .RuleFor(a => a.AllocationApplicationDateID, f => opts.AllocationApplicationDate?.DateId)
                        .RuleFor(a => a.AllocationPriorityDateID, f => opts.AllocationPriorityDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.AllocationExpirationDateID, f => opts.AllocationExpirationDate?.DateId)
                        .RuleFor(a => a.AllocationOwner, f => f.Name.FullName())
                        .RuleFor(a => a.AllocationBasisCv, f => opts.WaterAllocationBasis?.Name)
                        .RuleFor(a => a.AllocationLegalStatusCv, f => opts.LegalStatus?.Name)
                        .RuleFor(a => a.AllocationTypeCv, f => opts.WaterAllocationType?.Name)
                        .RuleFor(a => a.AllocationTimeframeEnd, f => opts.AllocationTimeframeStartDate?.Date.ToString("mm/dd"))
                        .RuleFor(a => a.AllocationTimeframeEnd, f => opts.AllocationTimeframeEndDate?.Date.ToString("mm/dd"))
                        .RuleFor(a => a.AllocationAmount, f => f.Random.Double(0, 1000))
                        .RuleFor(a => a.AllocationMaximum, f => f.Random.Double(0, 1000))
            ;

            switch (opts.RecordType ?? (new Faker()).PickRandom <WaterAllocationRecordType>())
            {
            case WaterAllocationRecordType.Ag:
                faker.RuleFor(a => a.IrrigatedAcreage, f => f.Random.Double(0, 10000))
                .RuleFor(a => a.CropTypeCV, f => opts.CropType?.Name)
                .RuleFor(a => a.IrrigationMethodCV, f => opts.IrrigationMethod?.Name)
                .RuleFor(a => a.AllocationCropDutyAmount, f => f.Random.Double(0, 1000));
                break;

            case WaterAllocationRecordType.Power:
                faker.RuleFor(a => a.GeneratedPowerCapacityMW, f => f.Random.Double(0, 10000));
                break;

            case WaterAllocationRecordType.Civilian:
                faker.RuleFor(a => a.PopulationServed, f => f.Random.Long(0, 10000000))
                .RuleFor(a => a.CommunityWaterSupplySystem, f => f.Address.City())
                .RuleFor(a => a.CustomerTypeCV, f => opts.CustomerType?.Name)
                .RuleFor(a => a.SdwisidentifierCV, f => opts.SDWISIdentifier?.Name);
                break;
            }

            return(faker);
        }
Ejemplo n.º 5
0
        public static SiteVariableAmountsFact Create(SiteVariableAmountsFactBuilderOptions opts)
        {
            var faker = new Faker <SiteVariableAmountsFact>()
                        .RuleFor(a => a.OrganizationId, f => opts.OrganizationsDim?.OrganizationId ?? OrganizationsDimBuilder.GenerateId())
                        .RuleFor(a => a.SiteId, f => opts.SiteDim?.SiteId ?? SitesDimBuilder.GenerateId())
                        .RuleFor(a => a.VariableSpecificId, f => opts.VariablesDim?.VariableSpecificId ?? VariablesDimBuilder.GenerateId())
                        .RuleFor(a => a.WaterSourceId, f => opts.WaterSourcesDim?.WaterSourceId ?? WaterSourcesDimBuilder.GenerateId())
                        .RuleFor(a => a.MethodId, f => opts.MethodsDim?.MethodId ?? MethodsDimBuilder.GenerateId())
                        .RuleFor(a => a.TimeframeStartID, f => opts.TimeframeStart?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.TimeframeEndID, f => opts.TimeframeEnd?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDateID, f => opts.DataPublicationDate?.DateId ?? DateDimBuilder.GenerateId())
                        .RuleFor(a => a.DataPublicationDoi, f => f.Random.Words(3))
                        .RuleFor(a => a.ReportYearCv, f => opts.ReportYearCv?.Name)
                        .RuleFor(a => a.Amount, f => opts.Amount ?? f.Random.Double(1, 10000))
                        .RuleFor(a => a.PrimaryUseCategoryCV, f => opts.PrimaryBeneficialUsesCv?.Name)
            ;

            switch (opts.RecordType ?? (new Faker()).PickRandom <SiteVariableAmountsRecordType>())
            {
            case SiteVariableAmountsRecordType.Ag:
                faker.RuleFor(a => a.IrrigatedAcreage, f => f.Random.Double(0, 10000))
                .RuleFor(a => a.CropTypeCv, f => opts.CropType?.Name)
                .RuleFor(a => a.IrrigationMethodCv, f => opts.IrrigationMethod?.Name)
                .RuleFor(a => a.AllocationCropDutyAmount, f => f.Random.Double(0, 1000));
                break;

            case SiteVariableAmountsRecordType.Power:
                faker.RuleFor(a => a.PowerGeneratedGwh, f => f.Random.Double(0, 10000));
                break;

            case SiteVariableAmountsRecordType.Civilian:
                faker.RuleFor(a => a.PopulationServed, f => f.Random.Long(0, 10000000))
                .RuleFor(a => a.CommunityWaterSupplySystem, f => f.Address.City())
                .RuleFor(a => a.CustomerTypeCv, f => opts.CustomerType?.Name)
                .RuleFor(a => a.SDWISIdentifierCv, f => opts.SDWISIdentifier?.Name);
                break;
            }

            return(faker);
        }