Remove inventory, delete transactions
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using NLog;
|
||||
|
||||
namespace InventoryTraker.Web.Attributes
|
||||
{
|
||||
public class ActionLogAttribute : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
if (filterContext != null)
|
||||
{
|
||||
var controller = filterContext.RouteData.Values["controller"].ToString();
|
||||
var action = filterContext.RouteData.Values["action"].ToString();
|
||||
var username = filterContext.HttpContext.User.Identity.Name;
|
||||
var loggerName = $"{controller}Controller.{action}";
|
||||
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => $"{i.Key}: {{{i.Value}}}"));
|
||||
|
||||
var hostAddress = filterContext.HttpContext.Request.UserHostAddress;
|
||||
|
||||
LogManager.GetLogger(loggerName)
|
||||
.Info("UserHostAddress: {0}, username: {1}, params: {{{2}}}", hostAddress, username, @params);
|
||||
}
|
||||
base.OnActionExecuting(filterContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user