Example #1
0
        public static IEnumerable <BackendActionLog> CreateLogs(BackendActionContext actionContext, IBackendActionLogRepository repository)
        {
            var ids    = actionContext.Entities.Where(ent => ent.Id.HasValue).Select(ent => ent.Id.Value).ToArray();
            var titles = repository.GetEntityTitles(actionContext.EntityTypeCode, actionContext.ParentEntityId, ids).ToDictionary(n => n.Value, m => m.Text);

            return(actionContext.Entities
                   .Select(ent => new BackendActionLog
            {
                EntityId = ent.Id,
                EntityStringId = ent.StringId,
                EntityTitle = ent.Id.HasValue && titles.ContainsKey(ent.Id.Value.ToString())
                        ? titles[ent.Id.Value.ToString()].Left(255)
                        : null,
                ActionCode = actionContext.ActionCode,
                ActionTypeCode = actionContext.ActionTypeCode,
                EntityTypeCode = actionContext.EntityTypeCode,
                ParentEntityId = actionContext.ParentEntityId,
                ExecutionTime = DateTime.Now,
                UserId = QPContext.CurrentUserId
            })
                   .ToArray());
        }