From 017f7a2e7bac7686a3b6dde5a3c586f99a6df530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Tue, 9 Feb 2021 16:28:13 +0100 Subject: [PATCH] onions --- Controller/HanyadikHetVanService.cs | 27 +++++++++++++++++++ Controllers/HanyadikHetVanController.cs | 14 +++++----- HanyadikHetVan.cs => DTO/HanyadikHetVanDTO.cs | 4 +-- Startup.cs | 2 +- 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 Controller/HanyadikHetVanService.cs rename HanyadikHetVan.cs => DTO/HanyadikHetVanDTO.cs (80%) diff --git a/Controller/HanyadikHetVanService.cs b/Controller/HanyadikHetVanService.cs new file mode 100644 index 0000000..fcb7437 --- /dev/null +++ b/Controller/HanyadikHetVanService.cs @@ -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 _logger; + private IConfiguration _configuration; + + public HanyadikHetVanService(ILogger logger, IConfiguration configuration) + { + _configuration = configuration; + _logger = logger; + } + + public HanyadikHetVanDTO HanyadikHetVan() + { + return new HanyadikHetVanDTO(); + } + } +} diff --git a/Controllers/HanyadikHetVanController.cs b/Controllers/HanyadikHetVanController.cs index 3882fad..d6cd888 100644 --- a/Controllers/HanyadikHetVanController.cs +++ b/Controllers/HanyadikHetVanController.cs @@ -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; @@ -11,17 +12,18 @@ namespace hanyadikhetvan.Controllers [Route("[controller]")] public class HanyadikHetVanController : ControllerBase { - private readonly ILogger _logger; - public HanyadikHetVanController(ILogger logger) + private readonly HanyadikHetVanService _service; + + public HanyadikHetVanController(HanyadikHetVanService service) { - _logger = logger; + _service = service; } [HttpGet] - public HanyadikHetVan Get() + public HanyadikHetVanDTO Get() { - return new HanyadikHetVan(); + return _service.HanyadikHetVan(); } } } diff --git a/HanyadikHetVan.cs b/DTO/HanyadikHetVanDTO.cs similarity index 80% rename from HanyadikHetVan.cs rename to DTO/HanyadikHetVanDTO.cs index 50c566f..cc4da23 100644 --- a/HanyadikHetVan.cs +++ b/DTO/HanyadikHetVanDTO.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace hanyadikhetvan +namespace hanyadikhetvan.DTO { - public class HanyadikHetVan + public class HanyadikHetVanDTO { public int HanyadikHet => (DateTime.Now - (DateTime.Parse(Environment.GetEnvironmentVariable("HANYADIKHET_STARTDATE")))).Days / 7; } diff --git a/Startup.cs b/Startup.cs index fd32b2c..38c9083 100644 --- a/Startup.cs +++ b/Startup.cs @@ -26,7 +26,7 @@ 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(); services.AddControllers(); }