using HRD.WebApi.DAL;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;

namespace HRD.WebApi.Controllers
{
    [Route("api/[controller]")]
    [Produces("application/json")]
    [ApiController]
    public abstract class BaseMiniController : Microsoft.AspNetCore.Mvc.Controller
    {
        protected readonly ILogger _logger;
        public readonly WebApiBaseContext Context;

        public BaseMiniController(WebApiBaseContext webApiBaseContext, ILogger logger)
        {
            Context = webApiBaseContext;
            _logger = logger;
        }

        [NonAction]
        public void WriteLogException(Exception exception, String entityMessage = null)
        {
            _logger.LogError(exception, "{entityMessage}", entityMessage);
        }
    }
}