// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); var appSettings = appConfig.Get <AppSettings>(); DIRepositoryModule.RegisterModule(services, appSettings.FurtherDbConnectionString); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/User/Login"; options.AccessDeniedPath = "/User/Login"; options.SlidingExpiration = true; }); services.AddTransient <IUserService, UserService>(); services.AddTransient <ICompanyService, CompanyService>(); services.AddAutoMapper(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var connectionStrings = Configuration.GetSection("ConnectionStrings"); //mongodb var mongoCs = connectionStrings.GetValue <string>("MongoConnectionString"); var mongoDbName = connectionStrings.GetValue <string>("MongoDatabase"); //register services services.AddTransient <IRestaurantService, RestaurantService>(); //dependency injection module DIRepositoryModule.RegisterRepositories(services, mongoCs, mongoDbName); //swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My Api", Version = "v1" }); }); //cors services.AddCors(); }
public void ConfigureServices(IServiceCollection services) { var connectionString = Configuration.GetValue <string>("SQLConnectionString"); //Dipendency Injection Configuration services.AddTransient <IHomeService, HomeService>(); //Dipendency Injection Module DIRepositoryModule.RegisterRepositories(services, connectionString); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); var connectionStrings = Configuration.GetSection("ConnectionStrings"); //Mongo DB var mongoCs = connectionStrings.GetValue <string>("MongoConncetionString"); var mongoDbName = connectionStrings.GetValue <string>("MongoDatabase"); //NpgSql DB var npgSqlCs = connectionStrings.GetValue <string>("NpgSqlDatabase"); //register services services.AddTransient <IRestaurantService, RestaurantService>(); services.AddTransient <IOrderService, OrderService>(); //Dependency Injection Module DIRepositoryModule.RegisterRepositories(services, mongoCs, mongoDbName, npgSqlCs); //swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My Api", Version = "v1" }); }); //JWT Authentication var key = Encoding.UTF8.GetBytes(Configuration.GetSection("ApplicationSettings").GetValue <string>("JWT_secret")); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = false; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false, ClockSkew = TimeSpan.Zero }; }); //cors services.AddCors(); }
public void ConfigureServices(IServiceCollection services) { //Dipendency Injection Configuration services.AddTransient <IMatchService, MatchService>(); services.AddTransient <IBuyService, BuyService>(); services.AddTransient <IUserService, UserService>(); //Dipendency Injection Module DIRepositoryModule.RegisterRepositories(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
public void ConfigureServices(IServiceCollection services) { //DipendInjecConfig services.AddTransient <IHomeService, HomeService>(); //DipendInjecModule DIRepositoryModule.RegisterRepositories(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); // Dependency injection configuration services.AddTransient <IStudentService, StudentService>(); services.AddTransient <IProjectService, ProjectService>(); DIRepositoryModule.RegisterRepositories(services); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddTransient <IToDoTaskService, ToDoTaskService>(); services.AddTransient <IUserService, UserService>(); services.AddTransient <ISubTaskService, SubTaskService>(); DIRepositoryModule.RegisterRepositories(services); services.AddDbContext <ToDoTaskDbContext>(x => x.UseSqlServer("Server=.\\SQLExpress;Database=ToDoTaskDb;Trusted_Connection=True")); }