public async Task <TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <TResponse> next)
        {
            if (request is IGlobalConfigChange)
            {
                var changeRequest = (IGlobalConfigChange)request;

                // Context property injection
                var configContext = (GlobalConfigChangeContext)_serviceProvider.GetService(typeof(GlobalConfigChangeContext));
                changeRequest.ConfigContext = configContext;

                var response = await next();

                bool hasChanged = changeRequest.ConfigContext.Result != null;
                if (hasChanged)
                {
                    ChangeIntent  intent  = changeRequest.ConfigContext.Intent;
                    ChangedResult changed = changeRequest.ConfigContext.Result;

                    if (intent != null && changed != null && !IsBySsSystem(changed.UserId))
                    {
                        var dbContext = (IApplicationDbContext)_serviceProvider.GetService(typeof(IApplicationDbContext));

                        GlobalConfigChangeLog log = BuildLog(intent, changed);
                        dbContext.GlobalConfigChangeLogs.Add(log);
                        await dbContext.SaveChangesAsync(cancellationToken);
                    }
                }

                return(response);
            }
            else
            {
                return(await next());
            }
        }
        private GlobalConfigChangeLog BuildLog(ChangeIntent intent, ChangedResult result)
        {
            var log = new GlobalConfigChangeLog();

            log.ReferenceId      = intent.ReferenceId;
            log.ConfigCategory   = intent.ConfigCategory;
            log.Description      = intent.ChangeDescription;
            log.UserId           = result.UserId;
            log.UserName         = result.UserName;
            log.GcaOid           = result.OrgUnitOid;
            log.SecurityServerId = result.SecurityServerId;
            log.LogTime          = DateTime.Now;
            log.StateChange      = result.State;

            return(log);
        }