Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AccessLogContext context, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=AccessLog}/{action=Verify}/{id?}");
            });

            loggerFactory.AddFile("logs/agecheckconcept-{Date}.log");

            // Perform initial database set-up
            AccessLogInitialiser.Initialise(context);
        }
        public static void Initialise(AccessLogContext context)
        {
            if (context.AccessLogs.Any())
            {
                return;
            }

            Seed(context);
        }
Exemple #3
0
        public AccessLogTestBase()
        {
            var options = new DbContextOptionsBuilder <AccessLogContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;

            _context = new AccessLogContext(options);

            _context.Database.EnsureCreated();

            AccessLogInitialiser.Initialise(_context);
        }
        private static void Seed(AccessLogContext context)
        {
            var accessLogs = new[]
            {
                new AccessLog
                {
                    SubmittedDateTime = DateTime.Now.AddHours(-1),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB         = DateTime.Now.AddYears(-10),
                    IsSuccess   = true,
                    IsLockedOut = false
                },
                new AccessLog
                {
                    SubmittedDateTime = DateTime.Now.AddHours(-2),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB         = DateTime.Now.AddYears(-20),
                    IsSuccess   = false,
                    IsLockedOut = false
                },
                new AccessLog
                {
                    SubmittedDateTime = DateTime.Now.AddHours(-3),
                    UserName          = "******",
                    EmailAddress      = "*****@*****.**",
                    DOB         = DateTime.Now.AddYears(-30),
                    IsSuccess   = true,
                    IsLockedOut = false
                }
            };

            context.AddRange(accessLogs);
            context.SaveChanges();
        }
Exemple #5
0
 public AccessLogService(AccessLogContext context)
 {
     _context = context;
 }