Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <CursodbContext>(builder => {
                var connection = Configuration.GetConnectionString("ConexionDb");
                var dbOptions  = new DbContextOptionsBuilder <CursodbContext>()
                                 .UseSqlServer(connection).Options;

                using var db = new CursodbContext(dbOptions);
                db.Database.EnsureCreated();
            });
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Ecomerce API-"
                });
            });
        }
 public CarroController(CursodbContext context)
 {
     dbContext = context;
 }
 public CompraModels(CursodbContext context)
 {
     dbContext = context;
 }
 public ProductosController(CursodbContext context)
 {
     dbContext = context;
 }
 public ClientesController(CursodbContext context)
 {
     dbContext = context;
 }
 public OrdenesController(CursodbContext context)
 {
     dbContext = context;
 }