public AddDonationState(LazyDbConnection lazyDbConnection) : base("donation_state", "donation_type_id, name", "@DonationTypeId, @Name", DatabaseType.Sqlite) { }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddMeteorJsonConverters(); Directory.CreateDirectory("data"); EnvVars.SetDefaultValue(EnvVarKeys.DbUri, "Data Source=data/main.db"); services.AddSingleton <IDbConnectionFactory, SqliteDbConnectionFactory>(); services.AddScoped <LazyDbConnection>(); using var lazyDbConnection = new LazyDbConnection(new SqliteDbConnectionFactory()); new CreateDatabase(lazyDbConnection).ExecuteAsync().Wait(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Distributor API", Version = "v1" }); }); services.AddCors(x => x .AddDefaultPolicy(y => y .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod())); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = "https://id.skyth.ir"; options.RequireHttpsMetadata = true; options.TokenValidationParameters = new TokenValidationParameters { RoleClaimType = "role", ValidateIssuer = true, ValidateLifetime = true, ValidAudiences = new[] { "mahak.dist" } }; }); services.AddAuthorization(options => { options.AddPolicy("Admin", builder => builder.RequireClaim("scope", "mahak.dist")); options.AddPolicy("Distributor", builder => builder.RequireClaim("scope", "mahak.dist.dist")); }); }
public ScheduleTypeController(ILogger <ScheduleTypeController> logger, LazyDbConnection lazyDbConnection) { _logger = logger; _lazyDbConnection = lazyDbConnection; }
public CreateDatabase(LazyDbConnection lazyDbConnection) : base(lazyDbConnection) { }
public DistributorLocationController(ILogger <DistributorLocationController> logger, LazyDbConnection lazyDbConnection) { _logger = logger; _lazyDbConnection = lazyDbConnection; }
public DonationController(ILogger <DonationController> logger, LazyDbConnection lazyDbConnection) { _logger = logger; _lazyDbConnection = lazyDbConnection; }
public OperationLogger(LazyDbConnection lazyDbConnection) { _lazyDbConnection = lazyDbConnection; }