add content type routing
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-02-09 19:20:59 +01:00
parent 2ab8648a71
commit 5d49b1fc39
4 changed files with 43 additions and 6 deletions

View 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"]);
}
}
}

View File

@ -19,9 +19,9 @@ namespace hanyadikhetvan
_logger = logger;
}
public HanyadikHetVanDTO HanyadikHetVan()
public int HanyadikHetVan()
{
return new HanyadikHetVanDTO(_configuration["HanyadikHetVan:StartDate"]);
return new HanyadikHetVanDTO(_configuration["HanyadikHetVan:StartDate"]).HanyadikHet;
}
}
}

View File

@ -9,19 +9,29 @@ using System.Threading.Tasks;
namespace hanyadikhetvan.Controllers
{
[ApiController]
[Route("[controller]")]
[Route("/")]
public class HanyadikHetVanController : ControllerBase
{
private readonly HanyadikHetVanJsonService _jsonservice;
private readonly HanyadikHetVanService _service;
public HanyadikHetVanController(HanyadikHetVanService service)
public HanyadikHetVanController(HanyadikHetVanJsonService jsonservice, HanyadikHetVanService service)
{
_jsonservice = jsonservice;
_service = service;
}
[HttpGet]
public HanyadikHetVanDTO Get()
[Consumes("application/json")]
public HanyadikHetVanDTO GetJson()
{
return _jsonservice.HanyadikHetVan();
}
[HttpGet]
public int Get()
{
return _service.HanyadikHetVan();
}

View File

@ -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.Configure<HanyadikHetVanService>(Configuration.GetSection("HanyadikHetVan"));
services.AddTransient<HanyadikHetVanJsonService>();
services.AddTransient<HanyadikHetVanService>();
services.AddControllers();
}