using System.Web.Http.Filters;
using System.Web.Mvc;

namespace InventoryTraker.Web.Utilities
{
	public static class ControllerContextExtensions
	{
		public static string GetLoggerName(this ControllerContext ctx)
		{
			var controller = ctx.RouteData.Values["controller"].ToString();
			var action = ctx.RouteData.Values["action"].ToString();
			return $"{controller}Controller.{action}";
		}

		public static string GetLoggerName(this HttpActionExecutedContext ctx)
		{
			var controller = ctx.ActionContext.ControllerContext.ControllerDescriptor.ControllerName;
			var action = ctx.ActionContext.ActionDescriptor.ActionName;
			return $"{controller}Controller.{action}";
		}
	}
}