public static void SeedDataContext(this UrlShortenDbContext context)
        {
            var urlShortens = new List <UrlShorten>
            {
                new UrlShorten()
                {
                    LongUrl      = @"https://www.google.com/",
                    ShortenedUrl = @"https://far.de/mnopq",
                    Token        = "mnopq",
                },
                new UrlShorten()
                {
                    LongUrl      = @"https://www.espncricinfo.com/story/_/id/28686811/bangladesh-19-champions-receive-heroes-welcome-mirpur",
                    ShortenedUrl = @"https://far.de/UVW",
                    Token        = @"UVW"
                },
                new UrlShorten()
                {
                    LongUrl      = @"https://en.wikipedia.org/wiki/Birthday_problem",
                    ShortenedUrl = @"https://far.de/HIJ",
                    Token        = "HIJ"
                }
            };

            context.UrlShortens.AddRange(urlShortens);
            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, IWebHostEnvironment env, UrlShortenDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            });

            app.UseMvc();
            //context.SeedDataContext();
        }