Esempio n. 1
0
        public static void EnsureSeedDataForContext(this ReCircleDbContext context)
        {
            if (context.Items.Any())
            {
                return;
            }

            var books = new List <Item>()
            {
                new Item()
                {
                    Title       = "New item",
                    Description = "its an item",
                    Id          = 0
                }
            };

            context.AddRange(books);
            context.SaveChanges();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ReCircleDbContext context, IdentityInitializer identity)
        {
            loggerFactory.AddConsole();

            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }

            //identity.Seed().Wait();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Item, Models.ItemDto>();
                cfg.CreateMap <Models.ItemForCreationDto, Entities.Item>();
            });

            logger.LogDebug("Configuration Complete");

            app.UseAuthentication();

            app.UseMvc();
        }