Пример #1
0
        public static AllocationBridgeSitesFact Create(AllocationBridgeSitesFactBuilderOptions opts)
        {
            var faker = new Faker <AllocationBridgeSitesFact>()
                        .RuleFor(a => a.SiteId, f => opts.SitesDim?.SiteId ?? SitesDimBuilder.GenerateId())
                        .RuleFor(a => a.AllocationAmountId, f => opts.AllocationAmountsFact?.AllocationAmountId ?? AllocationAmountsFactBuilder.GenerateId())
            ;

            return(faker);
        }
Пример #2
0
        public static async Task <AllocationBridgeSitesFact> Load(WaDEContext db, AllocationBridgeSitesFactBuilderOptions opts)
        {
            opts.SitesDim = opts.SitesDim ?? await SitesDimBuilder.Load(db);

            opts.AllocationAmountsFact = opts.AllocationAmountsFact ?? await AllocationAmountsFactBuilder.Load(db);

            var item = Create(opts);

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

            return(item);
        }