Esempio n. 1
0
 public async Task Handle(UserActionNotification notification, CancellationToken cancellationToken)
 {
     try
     {
         await _auditLogRepository.AddAsync(new AuditLog()
         {
             Action   = notification.Action,
             User     = notification.User,
             Time     = DateTime.UtcNow,
             Accounts = Mapper.Map <AccountRef[]>(notification.Accounts),
             Machines = Mapper.Map <MachineRef[]>(notification.Machines),
             MetaData = notification.Data
         });
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
     }
 }
Esempio n. 2
0
        private async Task <Result <Exception, Unit> > PersistLogInDB(AuditLog auditLog)
        {
            var auditLogIsValid = auditLog.Validate();

            if (auditLogIsValid.IsFailure)
            {
                return(auditLogIsValid.Failure);
            }

            var auditLogAddedCallback = await _auditRepository.AddAsync(auditLog);

            if (auditLogAddedCallback.IsFailure)
            {
                return(auditLogAddedCallback.Failure);
            }

            return(Unit.Successful);
        }