// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, QuoteDbContext quoteDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // quoteDbContext.Database.Migrate(); quoteDbContext.Database.EnsureCreated(); app.UseResponseCaching(); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseRouting(); 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, QuoteDbContext quoteDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = (c) => { var exception = c.Features.Get <IExceptionHandlerFeature>(); var message = "There has been some error"; var statusCode = exception.Error.GetType().Name switch { "ArgumentException" => HttpStatusCode.BadRequest, "DbUpdateConcurrencyException" => HttpStatusCode.NotFound, _ => HttpStatusCode.InternalServerError }; switch (statusCode) { case HttpStatusCode.BadRequest: message = "Invalid request"; break; case HttpStatusCode.NotFound: message = "No records found"; break; } c.Response.StatusCode = (int)statusCode; var content = Encoding.UTF8.GetBytes(message); c.Response.Body.WriteAsync(content, 0, content.Length); return(Task.CompletedTask); } }); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); quoteDbContext.Database.EnsureCreated(); app.UseSwagger(); app.UseSwaggerUI(swaggerUIOptions => { swaggerUIOptions.SwaggerEndpoint("/swagger/QuoteManagement/swagger.json", "QuoteManagementApi V1"); }); } }
public QuotesController(QuoteDbContext quoteContext) { _quoteContext = quoteContext; }
public HomeController(ILogger <HomeController> logger, QuoteDbContext context, IQuoteRepository repository) { _logger = logger; _context = context; _repository = repository; }
public HomeController(QuoteDbContext db) { _db = db; }
public QuotesController(QuoteDbContext context) { _context = context; }
public Repository(QuoteDbContext context) { this._context = context; DbSet = this._context.Set <T>(); }
public CharacterService(QuoteDbContext dbContext) { this.dbContext = dbContext; }
public QuoteRepository(QuoteDbContext ctx) { _ctx = ctx; }
public QuoteRepository(QuoteDbContext context) : base(context) { }
public QuoteService(QuoteDbContext dbContext) { this.dbContext = dbContext; }
public static IQueryable <Quote> GetAllAndRelated(QuoteDbContext context) { return(context.Quotes .Include(q => q.ParentQuote) .Include(q => q.Character)); }
public QuoteController(ILogger <QuoteController> logger, QuoteDbContext quoteDbContext) { _quoteDbContext = quoteDbContext; _logger = logger; }
public HomeController(ILogger <HomeController> logger, QuoteDbContext con) { _logger = logger; context = con; }