public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            MusicStoreEntities storeDB = new MusicStoreEntities();

            ActionLog log = new ActionLog()
            {
                Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
                Action = filterContext.ActionDescriptor.ActionName,
                IP = filterContext.HttpContext.Request.UserHostAddress,
                DateTime = filterContext.HttpContext.Timestamp
            };

            storeDB.ActionLogs.Add(log);
            storeDB.SaveChanges();

            base.OnActionExecuting(filterContext);
        }
        void IActionFilter.OnActionExecuting(ActionExecutingContext filterContext)
        {
            // TODO: Add your acction filter's tasks here

            // Log Action Filter Call
            MusicStoreEntities storeDB = new MusicStoreEntities();

            ActionLog log = new ActionLog()
            {
                Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
                Action = filterContext.ActionDescriptor.ActionName + " (Logged By: Custom Action Filter)",
                IP = filterContext.HttpContext.Request.UserHostAddress,
                DateTime = filterContext.HttpContext.Timestamp
            };

            storeDB.ActionLog.Add(log);
            storeDB.SaveChanges();

            this.OnActionExecuting(filterContext);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new ActionLog object.
 /// </summary>
 /// <param name="actionLogId">Initial value of the ActionLogId property.</param>
 /// <param name="controller">Initial value of the Controller property.</param>
 /// <param name="action">Initial value of the Action property.</param>
 /// <param name="iP">Initial value of the IP property.</param>
 /// <param name="dateTime">Initial value of the DateTime property.</param>
 public static ActionLog CreateActionLog(global::System.Int32 actionLogId, global::System.String controller, global::System.String action, global::System.String iP, global::System.DateTime dateTime)
 {
     ActionLog actionLog = new ActionLog();
     actionLog.ActionLogId = actionLogId;
     actionLog.Controller = controller;
     actionLog.Action = action;
     actionLog.IP = iP;
     actionLog.DateTime = dateTime;
     return actionLog;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ActionLogs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToActionLogs(ActionLog actionLog)
 {
     base.AddObject("ActionLogs", actionLog);
 }