// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseCors(builder =>
            {
                builder
                .WithOrigins("https://localhost:44315", "http://localhost:58722")
                .AllowAnyHeader()
                .AllowCredentials();
            });

            app.UseResponseCompression();

            app.UseAuthentication();

            app.UseMvc();

            UserSeed.Seed(app.ApplicationServices).Wait();
        }
Example #2
0
        private void MigrateDatabase(IApplicationBuilder app)
        {
            var genreConfiguration = Configuration.GetSection("Genre").Get <GenreConfiguration>();
            var userConfiguration  = Configuration.GetSection("User").Get <UserConfiguration>();
            var movieConfiguration = Configuration.GetSection("Movie").Get <MovieConfiguration>();
            //var movieGenreConfiguration = Configuration.GetSection("MovieGenre").Get<MovieGenreConfiguration>();
            var permissionConfiguration     = Configuration.GetSection("Permission").Get <PermissionConfiguration>();
            var reservationConfiguration    = Configuration.GetSection("Reservation").Get <ReservationConfiguration>();
            var roomConfiguration           = Configuration.GetSection("Room").Get <RoomConfiguration>();
            var roomPlanConfiguration       = Configuration.GetSection("RoomPlan").Get <RoomPlanConfiguration>();
            var scheduleConfiguration       = Configuration.GetSection("Schedule").Get <ScheduleConfiguration>();
            var scheduleSlotConfiguration   = Configuration.GetSection("ScheduleSlot").Get <ScheduleSlotConfiguration>();
            var seatTypeConfiguration       = Configuration.GetSection("SeatType").Get <SeatTypeConfiguration>();
            var seatPositionConfiguration   = Configuration.GetSection("SeatPosition").Get <SeatPositionConfiguration>();
            var locationConfiguration       = Configuration.GetSection("Location").Get <LocationConfiguration>();
            var roomAssignmentConfiguration = Configuration.GetSection("RoomAssignment").Get <RoomAssignmentConfiguration>();
            var roomTechnologyConfiguration = Configuration.GetSection("RoomTechnology").Get <RoomTechnologyConfiguration>();

            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <DatabaseContext>();
                context.Database.Migrate();

                GenreSeed.Seed(context, genreConfiguration.Genres);
                UserSeed.Seed(context, userConfiguration.Users);
                PermissionSeed.Seed(context, permissionConfiguration.Permissions);
                SeatTypeSeed.Seed(context, seatTypeConfiguration.SeatTypes);
                LocationSeed.Seed(context, locationConfiguration.Locations);
                RoomTechnologySeed.Seed(context, roomTechnologyConfiguration.RoomTechnologies);
            }
        }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            RoleSeed.Seed(builder);
            UserSeed.Seed(builder);
            UserRoleSeed.Seed(builder);
        }
        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.ApplyConfiguration(new UserMap());

            var users = UserSeed.Seed(builder.Entity <User> ());

            base.OnModelCreating(builder);
        }
        public static void EnsureSeeded(this BoilerplateContext context)
        {
            RolesSeed.Seed(context);
            context.SaveChanges();

            UserSeed.Seed(context);
            context.SaveChanges();
        }
        public static void Initialize(MoviesWebAppDbContext context)
        {
            context.Database.Migrate();

            UserSeed.Seed(context);
            MovieSeeds.Seed(context);
            ActorSeeds.Seed(context);
            ImgUrlSeed.Seed(context);
            ActorMovieSeeds.Seed(context);
        }
        protected override void Seed(CodeKata.Domain.CodeKataContext context)
        {
            // Deletes all data, from all tables, except for __MigrationHistory
            context.Database.ExecuteSqlCommand("sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'");
            context.Database.ExecuteSqlCommand("sp_MSForEachTable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0)) DELETE FROM ?'");
            context.Database.ExecuteSqlCommand("EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'");

            // proceed with the seed here
            var testUsers = UserSeed.Seed(context);

            SubmittedTaskSeed.Seed(context, testUsers);
        }
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                var context  = services.GetRequiredService <UserContext>();
                UserSeed.Seed(context);
            }
            host.Run();
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            #region "Mappers"
            UserMapping.Map(modelBuilder);
            #endregion

            #region "Seeders"
            UserSeed.Seed(modelBuilder);
            #endregion
        }
        public static void Initialize(RentingContext context)
        {
            context.Database.EnsureCreated();

            if (context.Users.Any())
            {
                return;   // DB has been seeded
            }
            CategorySeed.Seed(context).GetAwaiter().GetResult();
            UserSeed.Seed(context).GetAwaiter().GetResult();
            ItemsSeed.Seed(context).GetAwaiter().GetResult();
            RentsSeed.Seed(context).GetAwaiter().GetResult();
            RentedItemsSeed.Seed(context).GetAwaiter().GetResult();
        }
Example #11
0
        public void Configure(EntityTypeBuilder <User> configuration)
        {
            configuration.HasKey(a => a.Id);
            configuration.Property(a => a.Name).HasColumnType("varchar(255)").IsRequired();
            configuration.Property(a => a.Email).HasColumnType("varchar(255)").IsRequired();
            configuration.Property(a => a.Password).HasColumnType("varchar(255)").IsRequired();

            UserSeed seed = new UserSeed();

            configuration.HasData(seed.Seed());

            configuration.OwnsOne(a => a.Address).HasData(seed.SeedOwnesField_Address());

            configuration.ToTable("users");
        }
Example #12
0
        public void Configure(EntityTypeBuilder <User> builder)
        {
            builder.HasKey(p => p.Id);
            builder.HasIndex(p => p.Email).IsUnique();

            builder.HasQueryFilter(p => p.Active);

            builder.Property(p => p.CreatedAt)
            .HasDefaultValueSql("getdate()");

            builder.Property(p => p.Active)
            .HasDefaultValue(true);

            builder.HasData(UserSeed.Seed());
        }
Example #13
0
        protected override void Seed(Simple.Repository.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.
            UserSeed.Seed(context);

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
Example #14
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.Entity <AppUser>().HasMany <Chat>().WithOne(m => m.GetUser_1).OnDelete(DeleteBehavior.Restrict);
            builder.Entity <AppUser>().HasMany <Chat>().WithOne(m => m.GetUser_2).OnDelete(DeleteBehavior.Restrict);

            builder.Entity <Chat>().HasOne <AppUser>().WithMany(m => m.GetChates_1).OnDelete(DeleteBehavior.Restrict);
            builder.Entity <Chat>().HasOne <AppUser>().WithMany(m => m.GetChates_2).OnDelete(DeleteBehavior.Restrict);

            RoleSeed.Seed(builder);
            UserSeed.Seed(builder);
            UserRoleSeed.Seed(builder);
            CountrySeed.Seed(builder);
            CitySeed.Seed(builder);
        }
Example #15
0
 protected async Task WithUserSeeds()
 {
     await UserSeed.Seed();
 }
Example #16
0
        protected async Task WithBasicSeeds()
        {
            await RegionSeed.Seed();

            await UserSeed.Seed();
        }