/* LOG */ protected LogEntity CreateInternalLog(string message, UserEntity actor = null) { if (HttpContext?.Request == null) { return(null); } var controller = ControllerContext.RouteData.Values["controller"].ToString().FirstLetterToUpperCase(); var action = ControllerContext.RouteData.Values["action"].ToString(); var actionDescriptor = MvcHelper.GetActionDescriptor(HttpContext, controller, action); var actionAttr = actionDescriptor.GetCustomAttributes(typeof(CedActionAttribute), false).Cast <CedActionAttribute>().SingleOrDefault(); EntityType?entityType = null; var actionTypeAttr = actionAttr?.ActionType.GetAttribute <ActionTypeAttribute>(); if (actionTypeAttr != null) { entityType = actionTypeAttr.EntityType; } var log = new LogEntity { Url = HttpContext.Request.RawUrl, ActorUserId = actor?.UserId, ActorUserEmail = actor?.Email, Controller = controller, Action = action, MethodType = ControllerContext.RequestContext.HttpContext.Request.HttpMethod, Ip = HttpContext.Request.UserHostAddress, ActionType = actionAttr?.ActionType, EntityType = entityType, AdditionalInfo = message, CreatedOn = DateTime.Now }; log.LogId = LogServices.CreateLog(log); return(log); }