Example #1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <DataContext>(x => x
                                         .UseMySql(Configuration.GetConnectionString("DefaultConnection"))
                                         .ConfigureWarnings(Warnings => Warnings.Ignore(CoreEventId.IncludeIgnoredWarning)));
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
     .AddJsonOptions(opt => {
         opt.SerializerSettings.ReferenceLoopHandling =
             Newtonsoft.Json.ReferenceLoopHandling.Ignore;
     });
     services.AddCors();
     services.Configure <CloudinarySettings>(Configuration.GetSection("CloudinarySettings"));
     services.AddAutoMapper();
     services.AddTransient <Seed>();
     services.AddScoped <IAuthRepository, AuthRepository>();
     services.AddScoped <IDatingRepository, DatingRepository>();
     services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
     .AddJwtBearer(options => {
         options.TokenValidationParameters = new TokenValidationParameters
         {
             ValidateIssuerSigningKey = true,
             IssuerSigningKey         = new SymmetricSecurityKey(System.Text.Encoding.ASCII.GetBytes(Configuration.GetSection("AppSettings:Token").Value)),
             ValidateIssuer           = false,
             ValidateAudience         = false
         };
     });
     services.AddScoped <LogUserActivity>();
 }