コード例 #1
0
        public async Task <string> Handle(AnonymizeGdprDataCommand message, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(message.Username) && string.IsNullOrEmpty(message.CustomerNumber))
            {
                throw new ArgumentException("Neither username nor customer number are not specified or they are an empty strings");
            }

            var matcher = new PartyMatcher(message.Username, message.CustomerNumber);
            var data    = _applicationRepository.AnonymizeGdprData(matcher, message.Fake);

            if (!message.Fake)
            {
                await _applicationRepository.UnitOfWork.SaveEntitiesAsync();

                try
                {
                    await _auditClient.WriteLogEntry(AuditLogEntryAction.Execute, AuditLogEntryStatus.Success, "gdpr", message.CustomerNumber, "Anonymize gdpr data", data);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Audit error in AnonymizeGdprDataCommandHandler");
                }
            }
            return(data);
        }
コード例 #2
0
 public IActionResult ExportGdprData([FromQuery] string username, [FromQuery] string customerNumber)
 {
     if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(customerNumber))
     {
         return(BadRequest(new { message = "Neither username nor customer number are not specified or they are empty strings" }));
     }
     try
     {
         var matcher  = new PartyMatcher(username, customerNumber);
         var gdprData = _applicationRepository.ExportGdprData(matcher);
         return(Content(gdprData, "application/json"));
     }
     catch (DuplicateObjectException e)
     {
         return(BadRequest(new { message = e.Message }));
     }
 }