コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddDbContext <DriverRegistrationDbContext>(opt => opt.UseInMemoryDatabase("DriverRegistration"));
            services.AddScoped <IDriverRepository, DriverRepository>();
            services.AddScoped <ITruckageRepository, TruckageRepository>();
            services.AddScoped <ITruckTypeRepository, TruckTypeRepository>();
            using (var context = new DriverRegistrationDbContext()) { context.Database.EnsureCreated(); }

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new OpenApiInfo
                {
                    Title       = "Driver Rigistration",
                    Version     = "v1",
                    Description = "A presente API foi desenvolvida para controle do tráfego no terminal.",
                    Contact     = new OpenApiContact
                    {
                        Name = "Thiago Ângelo",
                        Url  = new Uri("https://github.com/Thiangelo/DriverRegistration")
                    }
                });
            });
        }
コード例 #2
0
 public DriverRepository(DriverRegistrationDbContext context)
 {
     _context = context;
 }