public AuctionController( ILogger <AuctionController> logger, IAuctionHandlerService auctionHandlerService ) { _logger = logger; _auctionHandlerService = auctionHandlerService; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseResponseCompression(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // CAREFUL: Place this before UsaStaticFiles app.UseExceptionHandler(a => a.Run(async context => { var exceptionHandlerPathFeature = context.Features.Get <IExceptionHandlerPathFeature>(); var exception = exceptionHandlerPathFeature.Error; var result = JsonConvert.SerializeObject(new Exception(exception.Message), new JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(result); })); app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapHub <AuctionHub>("/auction-hub"); endpoints.MapFallbackToFile("index.html"); }); IAuctionHandlerService auctionHandler = app.ApplicationServices.GetRequiredService <IAuctionHandlerService>(); auctionHandler.RefreshPlayersData(); }
public AuctionHub(IAuctionHandlerService auctionHandlerService) { _auctionHandlerService = auctionHandlerService; }