Compare commits
11 Commits
a093ceddc8
...
master
Author | SHA1 | Date | |
---|---|---|---|
04f6cf856a | |||
5d49b1fc39 | |||
2ab8648a71 | |||
017f7a2e7b | |||
c461f0461d | |||
92d2dabaf8 | |||
e93f188390 | |||
c25b2a92fe | |||
1f8ac7810d | |||
605658c13c | |||
aa2b07ddc1 |
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using hanyadikhetvan.DTO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -8,21 +9,31 @@ using System.Threading.Tasks;
|
||||
namespace hanyadikhetvan.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("/")]
|
||||
public class HanyadikHetVanController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<HanyadikHetVanController> _logger;
|
||||
|
||||
public HanyadikHetVanController(ILogger<HanyadikHetVanController> logger)
|
||||
private readonly HanyadikHetVanJsonService _jsonservice;
|
||||
private readonly HanyadikHetVanService _service;
|
||||
|
||||
|
||||
public HanyadikHetVanController(HanyadikHetVanJsonService jsonservice, HanyadikHetVanService service)
|
||||
{
|
||||
_logger = logger;
|
||||
_jsonservice = jsonservice;
|
||||
_service = service;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HanyadikHetVan Get()
|
||||
[Consumes("application/json")]
|
||||
public HanyadikHetVanDTO GetJson()
|
||||
{
|
||||
Console.WriteLine(Environment.GetEnvironmentVariable("HANYADIKHET_STARTDATE"));
|
||||
return new HanyadikHetVan();
|
||||
return _jsonservice.HanyadikHetVan();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public int Get()
|
||||
{
|
||||
return _service.HanyadikHetVan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
DTO/HanyadikHetVanDTO.cs
Normal file
19
DTO/HanyadikHetVanDTO.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace hanyadikhetvan.DTO
|
||||
{
|
||||
public class HanyadikHetVanDTO
|
||||
{
|
||||
private readonly DateTime startdate;
|
||||
|
||||
public HanyadikHetVanDTO(string startdate)
|
||||
{
|
||||
this.startdate = DateTime.Parse(startdate);
|
||||
}
|
||||
|
||||
public int HanyadikHet => (DateTime.Now - startdate).Days / 7;
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace hanyadikhetvan
|
||||
{
|
||||
public class HanyadikHetVan
|
||||
{
|
||||
public int HanyadikHet => DateTime.Now.Subtract(DateTime.Parse(Environment.GetEnvironmentVariable("HANYADIKHET_STARTDATE"))).Days / 7;
|
||||
}
|
||||
}
|
@ -18,6 +18,11 @@ namespace hanyadikhetvan
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureLogging(logging =>
|
||||
{
|
||||
logging.ClearProviders();
|
||||
logging.AddConsole();
|
||||
})
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
|
@ -22,6 +22,8 @@
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"HANYADIKHET_STARTDATE": "2021-02-08",
|
||||
"HanyadikHetVan__StartDate": "2021-02-08",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": "true",
|
||||
|
27
Services/HanyadikHetVanJsonService.cs
Normal file
27
Services/HanyadikHetVanJsonService.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using hanyadikhetvan.DTO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace hanyadikhetvan
|
||||
{
|
||||
public class HanyadikHetVanJsonService
|
||||
{
|
||||
private readonly ILogger<HanyadikHetVanJsonService> _logger;
|
||||
private IConfiguration _configuration;
|
||||
|
||||
public HanyadikHetVanJsonService(ILogger<HanyadikHetVanJsonService> logger, IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public HanyadikHetVanDTO HanyadikHetVan()
|
||||
{
|
||||
return new HanyadikHetVanDTO(_configuration["HanyadikHetVan:StartDate"]);
|
||||
}
|
||||
}
|
||||
}
|
27
Services/HanyadikHetVanService .cs
Normal file
27
Services/HanyadikHetVanService .cs
Normal file
@ -0,0 +1,27 @@
|
||||
using hanyadikhetvan.DTO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace hanyadikhetvan
|
||||
{
|
||||
public class HanyadikHetVanService
|
||||
{
|
||||
private readonly ILogger<HanyadikHetVanService> _logger;
|
||||
private IConfiguration _configuration;
|
||||
|
||||
public HanyadikHetVanService(ILogger<HanyadikHetVanService> logger, IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public int HanyadikHetVan()
|
||||
{
|
||||
return new HanyadikHetVanDTO(_configuration["HanyadikHetVan:StartDate"]).HanyadikHet;
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,8 @@ namespace hanyadikhetvan
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddTransient<HanyadikHetVanJsonService>();
|
||||
services.AddTransient<HanyadikHetVanService>();
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"HanyadikHetVan": {
|
||||
"StartDate": "2021-02-01"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
Reference in New Issue
Block a user