// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Social network keys services.Configure <SocialKeys>(Configuration.GetSection("SocialKeys")); services.AddSingleton <IConfiguration>(Configuration); // Add connection string to DbContext services.AddDbContext <EmpleadoDbContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); //Mapping instances services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IRoleRepository, RoleRepository>(); services.AddScoped <IPermissionRepository, PermissionRepository>(); services.AddScoped <IJobsService, JobsService>(); services.AddScoped <IJobRepository, JobRepository>(); services.AddScoped <ICategoriesService, CategoriesService>(); services.AddScoped <ICategoryRepository, CategoryRepository>(); services.AddScoped <IHireTypesService, HireTypesService>(); services.AddScoped <IHireTypeRepository, HireTypeRepository>(); services.AddScoped <ISecurityService, SecurityService>(); services.AddTransient <EmpleadoDbContext>(); #if DEBUG services.AddDbContext <EmpleadoDbContext>(options => options.UseSqlite($"Data Source=../mydb.db") ); #else services.AddDbContext <EmpleadoDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); #endif services.AddIdentity <User, Role>(); services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDistributedMemoryCache(); services.AddSession(); services.AddMvc(options => { options.Filters.Add(typeof(UnderMaintenanceFilterAttribute)); }).AddSessionStateTempDataProvider(); services.AddDbContext <EmpleadoDbContext>(); IocConfiguration.Init(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews().AddRazorRuntimeCompilation(); services.AddApplicationInsightsTelemetry(); services.AddFeatureManagement(); 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; }); // Registers the standard IFeatureManager implementation, which utilizes the .NET Standard configuration system. //Read more https://andrewlock.net/introducing-the-microsoft-featuremanagement-library-adding-feature-flags-to-an-asp-net-core-app-part-1/ #if DEBUG services.AddDbContext <EmpleaDbContext>(options => options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); #else services.AddDbContext <EmpleaDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); #endif services.Configure <AppServices.Services.TwitterConfig>(Configuration.GetSection("TwitterConfig")); services.Configure <LegacyApiClient>(Configuration); IocConfiguration.Init(Configuration, services); AuthConfiguration.Init(Configuration, services); services.AddElmah <XmlFileErrorLog>(options => { options.LogPath = "~/Helpers/log"; options.Path = "ErrorLogs"; options.CheckPermissionAction = context => context.User.Identity.IsAuthenticated; }); services.Configure <IISServerOptions>(options => { options.AllowSynchronousIO = true; }); services.AddSession(); //services.AddMvc();//option => option.EnableEndpointRouting = false).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); Console.WriteLine("Startup.ConfigureServices() End"); }