public static void Initialise(ZipCoContext context)
        {
            context.Database.EnsureCreated();

            // Look for any user
            if (context.Users.Any())
            {
                return; // DB has been seeded
            }

            // Create users
            List <User> users = new List <User>
            {
                new User {
                    Name = "Administrator", EmailAddress = "*****@*****.**", Password = Encryptor.EncryptMD5("Izi5XK0sLgpoHc56Nisv")
                }
            };

            foreach (User user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();
        }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ZipCoContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            RewriteOptions option = new RewriteOptions();

            option.AddRedirect("^$", "swagger");
            app.UseRewriter(option);

            app.UseHttpsRedirection();

            app.UseStaticFiles();

            app.UseCookiePolicy();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapRazorPages();
            });

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(q =>
            {
                q.SwaggerEndpoint("/swagger/v1/swagger.json", "ZipCo API v1");
            });

            DbInitialiser.Initialise(context);
        }
 public UserRepository(ZipCoContext context)
 {
     _context = context;
 }
示例#4
0
 public AccountRepository(ZipCoContext context)
 {
     _context = context;
 }