use iconfiguration
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-02-09 18:23:36 +01:00
parent 017f7a2e7b
commit 2ab8648a71
5 changed files with 14 additions and 2 deletions

View File

@ -21,7 +21,7 @@ namespace hanyadikhetvan
public HanyadikHetVanDTO HanyadikHetVan() public HanyadikHetVanDTO HanyadikHetVan()
{ {
return new HanyadikHetVanDTO(); return new HanyadikHetVanDTO(_configuration["HanyadikHetVan:StartDate"]);
} }
} }
} }

View File

@ -7,6 +7,13 @@ namespace hanyadikhetvan.DTO
{ {
public class HanyadikHetVanDTO public class HanyadikHetVanDTO
{ {
public int HanyadikHet => (DateTime.Now - (DateTime.Parse(Environment.GetEnvironmentVariable("HANYADIKHET_STARTDATE")))).Days / 7; private readonly DateTime startdate;
public HanyadikHetVanDTO(string startdate)
{
this.startdate = DateTime.Parse(startdate);
}
public int HanyadikHet => (DateTime.Now - startdate).Days / 7;
} }
} }

View File

@ -23,6 +23,7 @@
"launchUrl": "swagger", "launchUrl": "swagger",
"environmentVariables": { "environmentVariables": {
"HANYADIKHET_STARTDATE": "2021-02-08", "HANYADIKHET_STARTDATE": "2021-02-08",
"HanyadikHetVan__StartDate": "2021-02-08",
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": "true", "dotnetRunMessages": "true",

View File

@ -26,6 +26,7 @@ namespace hanyadikhetvan
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// services.Configure<HanyadikHetVanService>(Configuration.GetSection("HanyadikHetVan"));
services.AddTransient<HanyadikHetVanService>(); services.AddTransient<HanyadikHetVanService>();
services.AddControllers(); services.AddControllers();
} }

View File

@ -1,4 +1,7 @@
{ {
"HanyadikHetVan": {
"StartDate": "2021-02-01"
},
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",