// 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; }); DIModule.RegisterModule(services, Configuration.GetConnectionString("BudgetDbConnection")); services.AddAutoMapper(x => x.AddProfile <MapperProfile>()); services.AddMvc().AddNToastNotifyToastr(new ToastrOptions() { ProgressBar = false, PositionClass = ToastPositions.TopRight, CloseButton = true }); services.AddTransient <IIncomeService, IncomeService>(); services.AddTransient <IExpenseService, ExpenseService>(); services.AddTransient <IUserService, UserService>(); 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; }); //Configuring AppSettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); //Using AppSettings section var appSettings = appConfig.Get <AppSettings>(); DIModule.RegisterModule(services, appSettings.LamazonDbConnectionString); services.AddAutoMapper(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //services.AddDbContext<LamazonDbContext>(ob => ob.UseSqlServer( // Configuration.GetConnectionString("LamazonDbConnection") //)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); var appSettings = appConfig.Get <AppSettings>(); var secret = Encoding.ASCII.GetBytes(appSettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(secret), ValidateIssuer = false, ValidateAudience = false }; }); services.AddTransient <IFlowerService, FlowerService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IUserService, UserService>(); DIModule.RegisterModule(services, appSettings.AppConnectionString); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var connectionString = Configuration.GetConnectionString("DefaultConnection"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IUserService, UserService>(); services.AddTransient <IToDoService, ToDoService>(); //automapper var config = new MapperConfiguration(cfg => cfg.AddProfile(new MapperProfile())); var mapper = config.CreateMapper(); services.AddSingleton(mapper); //token authorisation services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = false, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = _localhost, //ValidAudience = _localhost, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("logInSecretKey@123456")) }; }); 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.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // get connection string from app settings json file var connectionString = Configuration.GetConnectionString("DefaultConnection"); DIModule.RegisterModule(services, connectionString); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); var connectionString = Configuration.GetConnectionString("DefaultConnection"); services.AddTransient <IUserServices, UserService>(); services.AddTransient <INoteServices, NoteService>(); DIModule.RegisterModule(services, connectionString); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetValue <string>("LamazonConnectionString"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); services.AddAutoMapper(); 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; }); //Configuring AppSettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); //Using AppSettings section var appSettings = appConfig.Get <AppSettings>(); DIModule.RegisterModule(services, appSettings.LamazonDbConnectionString); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/Users/LogIn"; options.AccessDeniedPath = "/Users/LogIn"; options.SlidingExpiration = true; }); services.AddMvc().AddNToastNotifyToastr(new ToastrOptions() { ProgressBar = false, PositionClass = ToastPositions.TopRight, CloseButton = true }); services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); services.AddTransient <IInvoiceService, InvoiceService>(); services.AddAutoMapper(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //services.AddDbContext<LamazonDbContext>(ob => ob.UseSqlServer( // Configuration.GetConnectionString("LamazonDbConnection") //)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //CORS services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Configuring AppSettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); // Using AppSettings //Configure jwt authentication: var appSettings = appConfig.Get <AppSettings>(); var secret = Encoding.ASCII.GetBytes(appSettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; } ).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(secret), ValidateIssuer = false, ValidateAudience = false }; } ); // IUserServce => new UserService(); services.AddTransient <IUserService, UserService>(); // INoteService => new NoteService(); services.AddTransient <IBookService, BookService>(); //Configure connection string: DIModule.RegisterModule(services, appSettings.LibraryAppConnectionString); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1).AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);; //get connection string from appsettings.json var connectionString = Configuration.GetConnectionString("DefaultConnection"); //important!!! - > every constructor that requires IUserService, this instantiates UserService instead !!!!! services.AddTransient <IUserService, UserService>(); services.AddTransient <IEmailService, EmailService>(); DIModule.RegisterModule(services, connectionString); //Server = CRMT-03; Database=MilanEmailDataBase; Trusted_Connection=True; }
public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetValue <string>("LamazonConnectionString"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); _ = services.AddAutoMapper(); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //Options pattern implementation //Configure AppSettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); //Using AppSettings var appSettings = appConfig.Get <AppSettings>(); string connectionString = appSettings.NoteAppConnectionString; //Read a value from the configuration file appSettings.json //string hosts = Configuration.GetValue<string>("AllowedHosts"); //Jwt token authentiaction configuration var secret = Encoding.ASCII.GetBytes(appSettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(secret), ValidateIssuer = false, ValidateAudience = false }; }); //Call the RegisterModule method that register all the repositories and the NoteDbContext class DIModule.RegisterModule(services, connectionString); //Registering services services.AddTransient <IUserService, UserService>(); services.AddTransient <INoteService, NoteService>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetValue <string>("RentacarConnectionString"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IAddEquipmentService, AdditionalEquipmentService>(); services.AddTransient <IVehicleService, VehicleService>(); services.AddTransient <IInvoiceService, InvoiceService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IUserService, UserService>(); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; //options.Cookie.MaxAge options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/User/Login"; options.AccessDeniedPath = "/User/Login"; options.SlidingExpiration = true; }); services.AddAutoMapper(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "RentaMkDrive API", Version = "v1" }); }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(options => { var resolve = options.SerializerSettings.ContractResolver; if (resolve != null) { (resolve as DefaultContractResolver).NamingStrategy = null; } //options.SerializerSettings = ReferenceLoopHandling.Ignore; }); }
// 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; }); // configuring appsettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); // using appsettings var appSettings = appConfig.Get <AppSettings>(); DIModule.RegisterModule(services, appSettings.LamazonDbContext); services.Configure <IdentityOptions>(opt => { }); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/Users/Login"; options.AccessDeniedPath = "/Home/"; options.SlidingExpiration = true; }); //register services services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); // Register automapper services.AddAutoMapper(); 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.AddControllersWithViews(); string connectionString = Configuration.GetValue <string>("LamazonConnectionString"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); services.AddTransient <IInvoiceService, InvoiceService>(); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/User/LogIn"; options.AccessDeniedPath = "/User/LogIn"; options.SlidingExpiration = true; }); services.AddAutoMapper(); services.AddMvc().AddNToastNotifyToastr(new ToastrOptions() { ProgressBar = true, PositionClass = ToastPositions.TopCenter }); services.AddMvc().AddNToastNotifyToastr(); }
// 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; }); //Configuring AppSettings section var appConfig = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appConfig); //Using AppSettings section var appSettings = appConfig.Get <AppSettings>(); services.AddAutoMapper(init => init.AddProfile <MappingProfile>() ); DIModule.RegisterModule(services, appSettings.BoomWorldDbConnectionString); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(60); options.LoginPath = "/Users/LogIn"; options.AccessDeniedPath = "/Home/Error"; options.SlidingExpiration = true; }); services.AddTransient <IUserService, UserService>(); services.AddTransient <IModService, ModService>(); services.AddTransient <ITopicService, TopicService>(); services.AddTransient <IPostService, PostService>(); services.AddTransient <ICommentService, CommentService>(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// 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; }); string connectionString = Configuration.GetValue <string>("LamazonConnectionString"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IUserService, UserService>(); services.AddTransient <IOrderService, OrderService>(); services.AddTransient <IProductService, ProductService>(); services.AddTransient <IInvoiceService, InvoiceService>(); services.AddAutoMapper(); services.ConfigureApplicationCookie(options => { options.Cookie.HttpOnly = true; options.ExpireTimeSpan = TimeSpan.FromMilliseconds(60); options.LoginPath = "/User/Login"; options.AccessDeniedPath = "/User/Login"; options.SlidingExpiration = true; }); services.AddMvc().AddNToastNotifyToastr(new ToastrOptions() { ProgressBar = true, PositionClass = ToastPositions.TopRight, CloseButton = true }); 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.AddControllers(); var connectionString = Configuration.GetConnectionString("DefaultConnection"); DIModule.RegisterModule(services, connectionString); services.AddTransient <IStudentService, StudentService>(); services.AddTransient <ISubjectService, SubjectService>(); //newtonson json services.AddControllersWithViews() .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); //swagger services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "College System Api", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); // get connection string from app settings json file var connectionString = Configuration.GetConnectionString("DefaultConnection"); var jwtSection = Configuration.GetSection("JwtSettings"); services.Configure <JwtSettings>(jwtSection); var jwtSettings = jwtSection.Get <JwtSettings>(); var seacret = Encoding.ASCII.GetBytes(jwtSettings.Seacret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(seacret), ValidateIssuer = false, ValidateAudience = false }; }); services.AddTransient <IUserService, UserService>(); services.AddTransient <INoteService, NoteService>(); DIModule.RegisterModule(services, connectionString); }
// 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; }); string connectionString = Configuration.GetValue <string>("idealDesignConnectionString"); DIModule.RegisterModule(services, connectionString); services.ConfigureApplicationCookie(option => { option.Cookie.HttpOnly = true; option.ExpireTimeSpan = TimeSpan.FromMinutes(60); option.LoginPath = "/Home/Index"; option.AccessDeniedPath = "/User/Login"; option.SlidingExpiration = true; }); services.AddAutoMapper(); services.AddTransient <IUserService, UserService>(); services.AddTransient <IProductService, ProductService>(); services.AddTransient <ICareerService, CareerService>(); services.AddMvc().AddNToastNotifyToastr(new ToastrOptions() { ProgressBar = true, PositionClass = ToastPositions.TopRight, CloseButton = true }); services.AddLocalization(option => { option.ResourcesPath = "Resources"; }); services.AddMvc() .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) //.AddModelBindingMessagesLocalizer(services) .AddDataAnnotationsLocalization(option => { var type = typeof(ViewResource); var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName); var factory = services.BuildServiceProvider().GetService <IStringLocalizerFactory>(); var localizer = factory.Create("ViewResource", assemblyName.Name); option.DataAnnotationLocalizerProvider = (t, f) => localizer; }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.Configure <RequestLocalizationOptions>(option => { var supportedCultures = new List <CultureInfo> { new CultureInfo("en"), new CultureInfo("en-US"), new CultureInfo("mk"), new CultureInfo("sq") }; option.DefaultRequestCulture = new RequestCulture("en"); // formating numbers, data, etc... option.SupportedCultures = supportedCultures; // UI strings that we have localized. option.SupportedUICultures = supportedCultures; }); //services.Configure<FormOptions>(x => //{ // x.MultipartBodyLengthLimit = 3145728; //}); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); DIModule.RegisterModule(services); }