Compare commits
13 Commits
544b22cd89
...
master
Author | SHA1 | Date | |
---|---|---|---|
04f6cf856a | |||
5d49b1fc39 | |||
2ab8648a71 | |||
017f7a2e7b | |||
c461f0461d | |||
92d2dabaf8 | |||
e93f188390 | |||
c25b2a92fe | |||
1f8ac7810d | |||
605658c13c | |||
aa2b07ddc1 | |||
a093ceddc8 | |||
4e8869f4d8 |
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using hanyadikhetvan.DTO;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -8,25 +9,31 @@ using System.Threading.Tasks;
|
|||||||
namespace hanyadikhetvan.Controllers
|
namespace hanyadikhetvan.Controllers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("/")]
|
||||||
public class HanyadikHetVanController : ControllerBase
|
public class HanyadikHetVanController : ControllerBase
|
||||||
{
|
{
|
||||||
private static readonly string[] Summaries = new[]
|
|
||||||
{
|
|
||||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly ILogger<HanyadikHetVanController> _logger;
|
private readonly HanyadikHetVanJsonService _jsonservice;
|
||||||
|
private readonly HanyadikHetVanService _service;
|
||||||
|
|
||||||
public HanyadikHetVanController(ILogger<HanyadikHetVanController> logger)
|
|
||||||
|
public HanyadikHetVanController(HanyadikHetVanJsonService jsonservice, HanyadikHetVanService service)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_jsonservice = jsonservice;
|
||||||
|
_service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public HanyadikHetVan Get()
|
[Consumes("application/json")]
|
||||||
|
public HanyadikHetVanDTO GetJson()
|
||||||
{
|
{
|
||||||
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) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
|
.ConfigureLogging(logging =>
|
||||||
|
{
|
||||||
|
logging.ClearProviders();
|
||||||
|
logging.AddConsole();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
|
"HANYADIKHET_STARTDATE": "2021-02-08",
|
||||||
|
"HanyadikHetVan__StartDate": "2021-02-08",
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"dotnetRunMessages": "true",
|
"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.
|
// 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.AddTransient<HanyadikHetVanJsonService>();
|
||||||
|
services.AddTransient<HanyadikHetVanService>();
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"HanyadikHetVan": {
|
||||||
|
"StartDate": "2021-02-01"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
|
Reference in New Issue
Block a user