Ejemplo n.º 1
0
 public static ReportingUnitsDim Create(ReportingUnitsDimBuilderOptions opts)
 {
     return(new Faker <ReportingUnitsDim>()
            .RuleFor(a => a.ReportingUnitUuid, f => f.Random.Uuid().ToString())
            .RuleFor(a => a.ReportingUnitNativeId, f => f.Random.Uuid().ToString())
            .RuleFor(a => a.ReportingUnitName, f => f.Company.CompanyName())
            .RuleFor(a => a.ReportingUnitTypeCv, f => opts.ReportingUnitType?.Name ?? f.Random.Word())
            .RuleFor(a => a.ReportingUnitUpdateDate, f => f.Date.Past())
            .RuleFor(a => a.ReportingUnitProductVersion, f => f.System.Version().ToString())
            .RuleFor(a => a.StateCv, f => opts.State?.Name ?? f.Address.StateAbbr())
            .RuleFor(a => a.EpsgcodeCv, f => opts.Epsgcode?.Name ?? f.Random.AlphaNumeric(10)));
 }
Ejemplo n.º 2
0
        public static async Task <ReportingUnitsDim> Load(WaDEContext db, ReportingUnitsDimBuilderOptions opts)
        {
            opts.ReportingUnitType = opts.ReportingUnitType ?? await ReportingUnitTypeBuilder.Load(db);

            opts.State = opts.State ?? await StateBuilder.Load(db);

            opts.Epsgcode = opts.Epsgcode ?? await EpsgcodeBuilder.Load(db);

            var item = Create(opts);

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

            return(item);
        }