60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using BusinessLogic.LookupLogic.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FwSearchApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class LookupController : ControllerBase
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
private readonly ILogger<LookupController> _logger;
|
|
private readonly ILookupLogic _lookupLogic;
|
|
|
|
public LookupController(IConfiguration configuration, ILogger<LookupController> logger, ILookupLogic lookupLogic)
|
|
{
|
|
_configuration = configuration;
|
|
_logger = logger;
|
|
_lookupLogic = lookupLogic;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetAllLookups")]
|
|
public async Task<JsonResult> GetAllLookups()
|
|
{
|
|
var result = await _lookupLogic.GetAllLookups();
|
|
if (result.GeneralResult != Datamodels.BusinessModels.GeneralResults.Success) {
|
|
throw new System.Exception("das war wohl nix");
|
|
}
|
|
_logger.LogInformation($"Lookups zur Verfügung gestellt von {nameof(GetAllLookups)}");
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetCategoriesById")]
|
|
public async Task<JsonResult> GetLookupCategoriesById(long id)
|
|
{
|
|
var result = await _lookupLogic.GetLookupCategoryById(id);
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetCategoriesByName")]
|
|
public async Task<JsonResult> GetLookupCategoriesByName(string categoryName)
|
|
{
|
|
var result = await _lookupLogic.GetLookupCategoryByName(categoryName);
|
|
return new JsonResult(result);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetActiveCategories")]
|
|
public async Task<JsonResult> GetActiveLookupCategories()
|
|
{
|
|
var result = await _lookupLogic.GetActiveLookupCategories();
|
|
return new JsonResult(result);
|
|
}
|
|
}
|
|
} |