public CosmosEmployeeService(ConnectionStringResolver connectionStringResolver, CompanyNameResolver companyNameResolver) { _companyName = companyNameResolver.GetCompanyName(); var connectionString = connectionStringResolver.GetConnectionString(); _cosmosClient = new CosmosClient(connectionString); }
public IUnitOfWork CreateUnitOfWork() { IServiceCollection services = new ServiceCollection(); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(_connectionStringResolver.GetConnectionString())); services.Configure <OperationalStoreOptions>(x => { }); var context = services.BuildServiceProvider().GetService <ApplicationDbContext>(); return(new UnitOfWork(context, _repositoryTypeMapper)); }
public void ConfigureServices(IServiceCollection services) { services.AddSingleton(Log.Logger); var connectionStringResolver = new ConnectionStringResolver(_configuration); services.AddSingleton(connectionStringResolver); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(connectionStringResolver.GetConnectionString())); services.AddDefaultIdentity <ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <ApplicationDbContext>(); services.AddHostedService <MigratorHostedService>(); services.AddIdentityServer().AddApiAuthorization <ApplicationUser, ApplicationDbContext>(); services.AddAuthentication().AddIdentityServerJwt(); services.AddControllersWithViews(); services.AddRazorPages(); services.AddServices(); services.MapRepositories(); services.AddManagers(); services.AddApiVersioning(); if (_env.IsDevelopment()) { services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Sentiment Analyser API", Version = "v1" }); options.SchemaFilter <EnumSchemaFilter>(); }); } Mapper.Initialize(); services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }