コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DezipperUnitOfWork" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="locationInfoRepository">The location info repository.</param>
 public DezipperUnitOfWork(
     DezipperContext context,
     ILocationInfoRepository locationInfoRepository)
 {
     _context      = context ?? throw new ArgumentNullException(nameof(context));
     LocationInfos = locationInfoRepository ?? throw new ArgumentNullException(nameof(locationInfoRepository));
 }
コード例 #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)
        {
            if (env.IsDevelopment())
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    DezipperContext context = serviceScope.ServiceProvider.GetRequiredService <DezipperContext>();

                    SeedTestData(context);
                }

                app.UseDeveloperExceptionPage();
            }

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v0.1/swagger.json", "DezipperAPI");
            });

            app.UseAuthentication();

            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
        }
コード例 #3
0
        private static void SeedTestData(DezipperContext context)
        {
            IList <LocationInfo> testLocations = new List <LocationInfo>();

            testLocations.Add(new LocationInfo(90000,
                                               "Los Angeles",
                                               "California",
                                               "CA",
                                               latitude: 34.052235,
                                               longitude: -118.243683));
            testLocations.Add(new LocationInfo(77000,
                                               "Austin",
                                               "Texas",
                                               "TX",
                                               latitude: 30.274613,
                                               longitude: -97.740353));
            testLocations.Add(new LocationInfo(58000,
                                               "Phoenix",
                                               "Arizona",
                                               "AZ",
                                               latitude: 33.739650,
                                               longitude: -112.054554));

            testLocations.Add(new LocationInfo(60000,
                                               "Chicago",
                                               "Illinois",
                                               "IL",
                                               latitude: 41.875430,
                                               longitude: -87.619033));
            testLocations.Add(new LocationInfo(30000,
                                               "Atlanta",
                                               "Georgia",
                                               "GA",
                                               latitude: 33.761086,
                                               longitude: -84.388335));

            context.LocationInfos.AddRange(testLocations);

            context.SaveChanges();
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocationInfoRepository"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public LocationInfoRepository(DezipperContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }