public static void EnsureSeedDataForContext(this RssFeedContext context)
        {
            if (context.RssFeed.Any())
            {
                return;
            }

            var feed = new RssFeed()
            {
                //Id = 1,
                Header         = "headerTest",
                Description    = "Description test",
                Source         = "source test",
                DateTime       = DateTime.Now,
                CreateDateTime = DateTime.Now
            };

            context.Add(feed);
            context.SaveChanges();
        }
예제 #2
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, RssFeedContext rssFeedContext)
 {
     loggerFactory.AddNLog();
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     app.UseStatusCodePages();
     app.UseMvc();
     rssFeedContext.EnsureSeedDataForContext();
     AutoMapper.Mapper.Initialize(cfg =>
     {
         cfg.CreateMap<DomainObjects.RssFeedDomainObj, Models.RssFeedDto>();
         cfg.CreateMap<Models.RssFeedDto, Entities.RssFeed>();
     });
     app.Run(async (context) =>
     {
         await context.Response.WriteAsync("Rss Feed Service is running");
     });
 }