31 lines
894 B
C#
31 lines
894 B
C#
using DigitalData.Modules.Logging;
|
|
using EnvelopeGenerator.Web.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using static EnvelopeGenerator.Web.Constants;
|
|
|
|
namespace EnvelopeGenerator.Web.Controllers
|
|
{
|
|
public class BaseController : Controller
|
|
{
|
|
internal DatabaseService database;
|
|
internal LogConfig logConfig;
|
|
internal Logger logger;
|
|
|
|
public BaseController(DatabaseService database, LoggingService logging)
|
|
{
|
|
this.database = database;
|
|
this.logConfig = logging.LogConfig;
|
|
this.logger = logging.LogConfig.GetLoggerFor(GetType().Name);
|
|
}
|
|
|
|
internal ObjectResult ErrorResponse(Exception e)
|
|
{
|
|
logger.Error(e);
|
|
return Problem(
|
|
statusCode: 500,
|
|
detail: e.Message,
|
|
type: ErrorType.ServerError.ToString());
|
|
}
|
|
}
|
|
}
|