示例#1
0
        private static void SeedSorMap(RepairsContext ctx)
        {
            List <SORContract> entities = new List <SORContract>();

            foreach (var code in SorCodes)
            {
                foreach (var contract in ContractReferences)
                {
                    entities.Add(new SORContract
                    {
                        ContractReference = contract,
                        Cost        = 5,
                        SorCodeCode = code
                    });
                }
            }

            ctx.Set <SORContract>().AddRange(entities);
            ctx.Set <SORContract>().Add(new SORContract
            {
                ContractReference = ContractReference,
                SorCodeCode       = SorCode,
                Cost = 1
            });
            ctx.Set <SORContract>().Add(new SORContract
            {
                ContractReference = DRSContractReference,
                SorCodeCode       = SorCode,
                Cost = 1
            });
        }
示例#2
0
        public static void SeedData(this RepairsContext ctx)
        {
            lock (_lockObj)
            {
                var hasSeedData = ctx.Trades.Any();

                if (!hasSeedData)
                {
                    SeedTrades(ctx);

                    SeedPriorities(ctx);

                    SeedSor(ctx);

                    SeedPropref();

                    SeedContractors(ctx);

                    SeedContracts(ctx);

                    SeedPropertyMap(ctx);

                    SeedSorMap(ctx);

                    SeedSecurityGroups(ctx);

                    SeedOperatives(ctx);
                }
            }
        }
示例#3
0
        private static void SeedContracts(RepairsContext ctx)
        {
            var generator = new Generator <Contract>()
                            .AddDefaultGenerators()
                            .AddGenerator(() => SeedCode(ContractReferences), (Contract c) => c.ContractReference)
                            .AddValue(DateTime.UtcNow.AddDays(-1), (Contract c) => c.EffectiveDate)
                            .AddValue(DateTime.UtcNow.AddDays(1), (Contract c) => c.TerminationDate)
                            .AddGenerator(() => PickCode(ContractorReferences), (Contract c) => c.ContractorReference)
                            .Ignore((Contract c) => c.PropertyMap)
                            .Ignore((Contract c) => c.SorCodeMap)
                            .Ignore((Contract c) => c.Contractor);

            ctx.Set <Contract>().AddRange(generator.GenerateList(10));
            ctx.Set <Contract>().Add(new Contract
            {
                ContractorReference = Contractor,
                ContractReference   = ContractReference,
                EffectiveDate       = DateTime.UtcNow.AddDays(-1),
                TerminationDate     = DateTime.UtcNow.AddDays(1),
            });
            ctx.Set <Contract>().Add(new Contract
            {
                ContractorReference = DRSContractor,
                ContractReference   = DRSContractReference,
                EffectiveDate       = DateTime.UtcNow.AddDays(-1),
                TerminationDate     = DateTime.UtcNow.AddDays(1),
            });
        }
示例#4
0
 private static void SeedOperatives(RepairsContext ctx)
 {
     ctx.Operatives.AddRange(new List <Operative>()
     {
         new Operative {
             Id = OperativeId, IsArchived = false, Name = "James o Operative", PayrollNumber = OperativePayrollId, Email = OperativeEmail
         }
     });
     ctx.SaveChanges();
 }
示例#5
0
        private static void SeedTrades(RepairsContext ctx)
        {
            var generator = new Generator <SorCodeTrade>()
                            .AddDefaultGenerators()
                            .Ignore((SorCodeTrade sct) => sct.Operatives)
                            .AddGenerator(() => SeedCode(TradeCodes), (SorCodeTrade sct) => sct.Code);

            ctx.Set <SorCodeTrade>().AddRange(generator.GenerateList(10));

            ctx.Set <SorCodeTrade>().Add(new SorCodeTrade
            {
                Code = Trade,
                Name = Trade
            });
        }
示例#6
0
        private static void SeedPriorities(RepairsContext ctx)
        {
            var generator = new Generator <SORPriority>()
                            .AddDefaultGenerators()
                            .AddGenerator(() => SeedCode(PriorityCodes), (SORPriority sp) => sp.PriorityCode)
                            .AddValue(true, (SORPriority sp) => sp.Enabled);

            ctx.Set <SORPriority>().AddRange(generator.GenerateList(3));
            ctx.Set <SORPriority>().Add(new SORPriority
            {
                Description       = Priority,
                PriorityCode      = PriorityId,
                Enabled           = true,
                PriorityCharacter = "A"
            });
        }
示例#7
0
        private static void SeedPropertyMap(RepairsContext ctx)
        {
            var generator = new Generator <PropertyContract>()
                            .AddDefaultGenerators()
                            .AddGenerator(() => PickCode(ContractReferences), (PropertyContract c) => c.ContractReference)
                            .AddGenerator(() => PickCode(PropertyReferences), (PropertyContract c) => c.PropRef)
                            .Ignore((PropertyContract c) => c.Contract);

            IEnumerable <PropertyContract> entities = generator.GenerateList(40).Distinct();

            ctx.Set <PropertyContract>().AddRange(entities);
            ctx.Set <PropertyContract>().Add(new PropertyContract
            {
                ContractReference = ContractReference,
                PropRef           = PropRef
            });
            ctx.Set <PropertyContract>().Add(new PropertyContract
            {
                ContractReference = DRSContractReference,
                PropRef           = PropRef
            });
        }
示例#8
0
        private static void SeedContractors(RepairsContext ctx)
        {
            var generator = new Generator <Contractor>()
                            .AddDefaultGenerators()
                            .AddGenerator(() => SeedCode(ContractorReferences), (Contractor c) => c.Reference)
                            .AddValue(null, (Contractor c) => c.Contracts);

            ctx.Set <Contractor>().AddRange(generator.GenerateList(5));
            ctx.Set <Contractor>().Add(new Contractor
            {
                Name      = Contractor,
                Reference = Contractor,
                UseExternalScheduleManager = false,
                ContractManagerEmail       = ContractorContractManagerEmail,
                CanAssignOperative         = true
            });
            ctx.Set <Contractor>().Add(new Contractor
            {
                Name      = DRSContractor,
                Reference = DRSContractor,
                UseExternalScheduleManager = true
            });
        }
示例#9
0
        private static void SeedSor(RepairsContext ctx)
        {
            var generator = new Generator <ScheduleOfRates>()
                            .AddDefaultGenerators()
                            .AddGenerator(() => SeedCode(SorCodes), (ScheduleOfRates sor) => sor.Code)
                            .AddGenerator(() => PickCode(TradeCodes), (ScheduleOfRates sor) => sor.TradeCode)
                            .AddGenerator(() => PickCode(PriorityCodes), (ScheduleOfRates sor) => sor.PriorityId)
                            .AddValue(true, (ScheduleOfRates sor) => sor.Enabled)
                            .Ignore((ScheduleOfRates sor) => sor.Priority)
                            .Ignore((ScheduleOfRates sor) => sor.Trade)
                            .Ignore((ScheduleOfRates sor) => sor.SorCodeMap);

            ctx.Set <ScheduleOfRates>().AddRange(generator.GenerateList(10));
            ctx.Set <ScheduleOfRates>().Add(new ScheduleOfRates
            {
                Enabled          = true,
                Cost             = 1,
                Code             = SorCode,
                ShortDescription = SorCode,
                LongDescription  = SorCode,
                PriorityId       = PriorityId,
                TradeCode        = Trade
            });
        }
 public OperativesGateway(RepairsContext context, ILogger <OperativesGateway> logger)
 {
     _context = context;
     _logger  = logger;
 }
 public AppointmentGateway(RepairsContext repairsContext)
 {
     _repairsContext = repairsContext;
 }
示例#12
0
 public SorPriorityGateway(RepairsContext context)
 {
     _priorities = context.SORPriorities;
 }
 public RepairsGateway(RepairsContext repairsContext, ICurrentUserService currentUserService)
 {
     _repairsContext     = repairsContext;
     _currentUserService = currentUserService;
 }
示例#14
0
 public ScheduleOfRatesGateway(RepairsContext context)
 {
     _context = context;
 }
示例#15
0
        private static void SeedSecurityGroups(RepairsContext ctx)
        {
            ctx.SecurityGroups.AddRange(new List <SecurityGroup>
            {
                new SecurityGroup {
                    GroupName = UserGroups.Agent, UserType = UserGroups.Agent
                },
                new SecurityGroup {
                    GroupName = UserGroups.ContractManager, UserType = UserGroups.ContractManager, VaryLimit = 10000000000
                },
                new SecurityGroup {
                    GroupName = ContractManagerLimit1000, UserType = UserGroups.ContractManager, VaryLimit = 1000
                },
                new SecurityGroup {
                    GroupName = UserGroups.Contractor, UserType = UserGroups.Contractor, ContractorReference = "contractor"
                },
                new SecurityGroup {
                    GroupName = DRSContractor, UserType = UserGroups.Contractor, ContractorReference = DRSContractor
                },
                new SecurityGroup {
                    GroupName = UserGroups.AuthorisationManager, UserType = UserGroups.AuthorisationManager, RaiseLimit = 10000000000
                },
                new SecurityGroup {
                    GroupName = AuthorisationManagerLimit1000, UserType = UserGroups.AuthorisationManager, RaiseLimit = 1000
                },
                new SecurityGroup {
                    GroupName = UserGroups.AuthorisationManager, UserType = UserGroups.Agent
                },

                new SecurityGroup {
                    GroupName = MultiContractor, UserType = UserGroups.Contractor, ContractorReference = DRSContractor
                },
                new SecurityGroup {
                    GroupName = MultiContractor, UserType = UserGroups.Contractor, ContractorReference = Contractor
                },

                new SecurityGroup {
                    GroupName = "raise50", RaiseLimit = 50
                },
                new SecurityGroup {
                    GroupName = "raise100", RaiseLimit = 100
                },
                new SecurityGroup {
                    GroupName = "raise150", RaiseLimit = 150
                },

                new SecurityGroup {
                    GroupName = "vary50", VaryLimit = 50
                },
                new SecurityGroup {
                    GroupName = "vary100", VaryLimit = 100
                },
                new SecurityGroup {
                    GroupName = "vary150", VaryLimit = 150
                },
                new SecurityGroup {
                    GroupName = UserGroups.Operative, UserType = UserGroups.Operative
                },
            });
            ctx.SaveChanges();
        }
 public JobStatusUpdateGateway(RepairsContext repairsContext, ICurrentUserService currentUserService)
 {
     _repairsContext     = repairsContext;
     _currentUserService = currentUserService;
 }
 public WorkOrderCompletionGateway(RepairsContext repairsContext, ICurrentUserService currentUserService)
 {
     _repairsContext     = repairsContext;
     _currentUserService = currentUserService;
 }
示例#18
0
 public RepairOrdersController(RepairsContext context)
 {
     _context = context;
 }
 public static void Teardown()
 {
     _context = null;
 }
示例#20
0
 public ScopedContext(IServiceProvider services)
 {
     _scope = services.CreateScope();
     DB     = _scope.ServiceProvider.GetRequiredService <RepairsContext>();
 }
示例#21
0
 public GroupsGateway(RepairsContext repairsContext)
 {
     _repairsContext = repairsContext;
 }