2024-02-23 14:42:30 +01:00

37 lines
1.1 KiB
C#

using DigitalData.Modules.Logging;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using static EnvelopeGenerator.Web.Constants;
namespace EnvelopeGenerator.Web.Controllers
{
public class BaseController : Controller
{
protected readonly IConfiguration _configuration;
internal DatabaseService database;
internal LogConfig logConfig;
internal State state;
public Logger logger;
public BaseController(DatabaseService database, LoggingService logging, IConfiguration configuration)
{
_configuration = configuration;
this.database = database;
this.logConfig = logging.LogConfig;
this.logger = logging.LogConfig.GetLogger();
this.state = database.State;
}
internal ObjectResult ErrorResponse(Exception e)
{
logger.Error(e);
return Problem(
statusCode: 500,
detail: e.Message,
type: ErrorType.ServerError.ToString());
}
}
}