public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery queryOptions) { var token = _httpContextAccessor.HttpContext.GetTokenAsync(OpenIdConnectParameterNames.AccessToken).GetAwaiter().GetResult(); var headers = new Metadata { { "Authorization", $"Bearer {token}" }, }; var client = new AuditLogClient(ChannelFactory.Create(_configuration["Services:AuditLog:Grpc"])); var entries = client.GetAuditLogEntries(new GetAuditLogEntriesRequest { ObjectId = queryOptions.ObjectId, }, headers); return(entries.Entries.Select(x => new AuditLogEntryDTO { Id = Guid.Parse(x.Id), ObjectId = x.ObjectId, UserId = Guid.Parse(x.UserId), Action = x.Action, Log = x.Log, UserName = x.UserName, CreatedDateTime = x.CreatedDateTime.ToDateTimeOffset(), }).ToList()); }
public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery queryOptions) { var query = _dbContext.Set <AuditLogEntry>() as IQueryable <AuditLogEntry>; if (queryOptions.UserId != Guid.Empty) { query = query.Where(x => x.UserId == queryOptions.UserId); } if (!string.IsNullOrEmpty(queryOptions.ObjectId)) { query = query.Where(x => x.ObjectId == queryOptions.ObjectId); } if (queryOptions.AsNoTracking) { query = query.AsNoTracking(); } var auditLogs = query.ToList(); var users = _dispatcher.Dispatch(new GetUsersQuery()); var rs = auditLogs.Join(users, x => x.UserId, y => y.Id, (x, y) => new AuditLogEntryDTO { UserId = x.UserId, Action = x.Action, ObjectId = x.ObjectId, Log = x.Log, CreatedDateTime = x.CreatedDateTime, UserName = y.UserName, }); return(rs.OrderByDescending(x => x.CreatedDateTime).ToList()); }
public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery query) { var auditLogs = _auditLogEntryRepository.Get(query); var users = _userRepository.GetAll(); var rs = auditLogs.Join(users, x => x.UserId, y => y.Id, (x, y) => new AuditLogEntryDTO { UserId = x.UserId, Action = x.Action, ObjectId = x.ObjectId, Log = x.Log, CreatedDateTime = x.CreatedDateTime, UserName = y.UserName, }); return(rs.OrderByDescending(x => x.CreatedDateTime).ToList()); }
public async Task <List <AuditLogEntryDTO> > HandleAsync(GetAuditEntriesQuery query, CancellationToken cancellationToken = default) { var auditLogs = _auditLogEntryRepository.Get(query); var users = _userRepository.GetAll(); var rs = auditLogs.Join(users, x => x.UserId, y => y.Id, (x, y) => new AuditLogEntryDTO { Id = x.Id, UserId = x.UserId, Action = x.Action, ObjectId = x.ObjectId, Log = x.Log, CreatedDateTime = x.CreatedDateTime, UserName = y.UserName, }); return(await _userRepository.ToListAsync(rs.OrderByDescending(x => x.CreatedDateTime))); }
public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery queryOptions) { var client = new AuditLogClient(ChannelFactory.Create("https://localhost:5002")); var entries = client.GetAuditLogEntries(new GetAuditLogEntriesRequest { ObjectId = queryOptions.ObjectId, }); return(entries.Entries.Select(x => new AuditLogEntryDTO { Id = Guid.Parse(x.Id), ObjectId = x.ObjectId, UserId = Guid.Parse(x.UserId), Action = x.Action, Log = x.Log, UserName = x.UserName, CreatedDateTime = x.CreatedDateTime.ToDateTimeOffset(), }).ToList()); }
public List <AuditLogEntryDTO> Handle(GetAuditEntriesQuery query) { return(_auditLogService.GetAuditLogEntries(query)); }
public Task <List <AuditLogEntryDTO> > HandleAsync(GetAuditEntriesQuery query) { return(_auditLogService.GetAuditLogEntriesAsync(query)); }
public Task <List <AuditLogEntryDTO> > HandleAsync(GetAuditEntriesQuery query, CancellationToken cancellationToken = default) { return(_auditLogService.GetAuditLogEntriesAsync(query)); }