예제 #1
0
        public static void EnsureSeedDataForContext(this DoormanContext context)
        {
            if (!context.Rooms.Any())
            {
                var rooms = new List <Room>
                {
                    new Room {
                        Description = "Computer Science Hall"
                    },
                    new Room {
                        Description = "Software Engineering Hall"
                    }
                };

                context.Rooms.AddRange(rooms);
            }

            context.SaveChanges();
        }
예제 #2
0
파일: Startup.cs 프로젝트: souldzin/doorman
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DoormanContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            context.EnsureSeedDataForContext();

            Mapper.Initialize(cfg => cfg.AddProfiles(Assembly.GetExecutingAssembly()));

            app.UseCors("CorsPolicy");

            app.UseWebSockets();

            app.UseSignalR(routes =>
            {
                routes.MapHub <DoormanHub>("doorman");
            });

            app.UseMvc();
        }