public static void Initialize(BugsContext context) { if (!context.Improvements.Any() || !context.Statuses.Any()) { Status st = new Status { Name = "New" }; Status st2 = new Status { Name = "Process" }; Status st3 = new Status { Name = "Solved" }; context.Statuses.AddRange(st, st2, st3); context.SaveChanges(); Improvement imp = new Improvement { Name = "TestSolveTask", Description = "testing" }; imp.Statuses.Add(st); imp.Statuses.Add(st3); imp.CurrentStatus = st.Name; Improvement imp2 = new Improvement { Name = "SecondTestSolveTask", Description = "testing2" }; imp2.Statuses.Add(st); imp2.Statuses.Add(st2); imp2.Statuses.Add(st3); imp2.CurrentStatus = st.Name; context.Improvements.AddRange(imp, imp2); context.SaveChanges(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BugsContext bugsContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DemoWebApi v1")); } bugsContext.Database.EnsureCreated(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BugsContext db) { db.Database.EnsureCreated(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("./swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = string.Empty; }); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public ProjectsController(BugsContext db) { DbContext = db; }
public TicketsController(BugsContext db) { DbContext = db; }
public SolveController(BugsContext context) { db = context; }
public HomeController(BugsContext context) { db = context; }
public BugsController(BugsContext context) { _context = context; }