namespace LaaProductionWeb.Services { using LaaProductionWeb.Data.Interfaces; using LaaProductionWeb.Services.Interfaces; using System; public class LoggerService : ILoggerService { private readonly IFluentSQL fluentSQL; public LoggerService(IFluentSQL fluentSQL) => this.fluentSQL = fluentSQL; public class Actions { public const string RUN = nameof(RUN); } public class LogModel { public long Id { get; internal set; } public DateTime Date { get; internal set; } = DateTime.Now; public string User { get; set; } public string Action { get; set; } public string Data { get; set; } } public void Log(Action logModel) { var model = new LogModel(); logModel?.Invoke(model); this.fluentSQL .CreateCommand($@" INSERT INTO [SoftwareFunctionsLog] ( [User] , [Action] , [Data]) VALUES (@{nameof(model.User)} , @{nameof(model.Action)} , @{nameof(model.Data)})") .SetParameter(nameof(model.User), model.User) .SetParameter(nameof(model.Action), model.Action) .SetParameter(nameof(model.Data), model.Data) .ExecuteNonQuery(); } } }