public UserService(IConfiguration configuration, TeamService teamService, LimitService limitService, EmailService emailService, SchedulearnContext schedulearnContext) { _configuration = configuration; _schedulearnContext = schedulearnContext; _teamService = teamService; _limitService = limitService; _emailService = emailService; }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseMiddleware(typeof(ErrorHandlingMiddleware)); } using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var options = serviceScope.ServiceProvider.GetService <DbContextOptions <SchedulearnContext> >(); var context = new SchedulearnContext(options); context.Database.Migrate(); } app.UseCors(builder => builder .AllowAnyMethod() .AllowAnyHeader() .WithOrigins("http://localhost:3000") .AllowCredentials()); app.UseWebSockets(); app.UseMiddleware(typeof(TransactionFilter)); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.Run(async(context) => { context.Response.StatusCode = 404; await context.Response.WriteAsync("{error: \"Endpoint does not exist\"}"); }); }
public JobTitleController(SchedulearnContext schedulearnContext) { _schedulearnContext = schedulearnContext; }
public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMemoryCache(); services.AddScoped <DbConnection>((serviceProvider) => { var dbConnection = new SqlConnection(Configuration.GetConnectionString("SchedulearnDatabase")); dbConnection.Open(); return(dbConnection); }); services.AddScoped <DbTransaction>((serviceProvider) => { var dbConnection = serviceProvider .GetService <DbConnection>(); return(dbConnection.BeginTransaction(IsolationLevel.ReadCommitted)); }); services.AddScoped <DbContextOptions <SchedulearnContext> >((serviceProvider) => { var dbConnection = serviceProvider.GetService <DbConnection>(); return(new DbContextOptionsBuilder <SchedulearnContext>() .UseLazyLoadingProxies() .UseSqlServer(dbConnection) .Options); }); services.AddScoped <SchedulearnContext>((serviceProvider) => { var transaction = serviceProvider.GetService <DbTransaction>(); var options = serviceProvider.GetService <DbContextOptions <SchedulearnContext> >(); var context = new SchedulearnContext(options); context.Database.UseTransaction(transaction); return(context); }); services.Configure <EmailSettings>(Configuration.GetSection("EmailSettings")); services.AddScoped <EmailService>(); services.AddScoped <UserService>(); services.AddScoped <LimitService>(); services.AddScoped <TeamService>(); services.AddScoped <TopicService>(); services.AddScoped <LearningDayService>(); services.AddScoped <SuggestionService>(); services.AddControllers().AddNewtonsoftJson(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidateAudience = true, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])) }; }); }
public SuggestionService(SchedulearnContext schedulearnContext) { _schedulearnContext = schedulearnContext; }
public TeamService(LimitService limitService, SchedulearnContext schedulearnContext) { _limitService = limitService; _schedulearnContext = schedulearnContext; }
public LimitService(SchedulearnContext schedulearnContext) { _schedulearnContext = schedulearnContext; }
public LearningDayService(SchedulearnContext schedulearnContext) { _schedulearnContext = schedulearnContext; }
public TopicController(TopicService topicService, SchedulearnContext schedulearnContext) { _topicService = topicService; _schedulearnContext = schedulearnContext; }
public LimitController(LimitService limitService, SchedulearnContext schedulearnContext) { _limitService = limitService; _schedulearnContext = schedulearnContext; }
public TopicService(LearningDayService learningDayService, TeamService teamService, SchedulearnContext schedulearnContext) { _schedulearnContext = schedulearnContext; _learningDayService = learningDayService; _teamService = teamService; }