public async Task <Unit> Handle(CancelAppealCommand request, CancellationToken cancellationToken) { _auditService.StartTracking(UserAction.CancelAppeal, request.UserId, request.UserName); var appealFiles = await _appealFileRepository.GetAllForApplication(request.ApplicationId); if (appealFiles != null) { foreach (var file in appealFiles) { _auditService.AuditDelete(file); _appealFileRepository.Remove(file.Id); } } var currentAppeal = await _appealRepository.GetByApplicationId(request.ApplicationId); if (currentAppeal != null) { _auditService.AuditDelete(currentAppeal); _appealRepository.Remove(currentAppeal.Id); } _auditService.Save(); return(Unit.Value); }
public async Task <Unit> Handle(DeleteAppealFileCommand request, CancellationToken cancellationToken) { var upload = await _appealFileRepository.Get(request.ApplicationId, request.FileName); if (upload is null) { throw new InvalidOperationException($"Appeal file {request.FileName} does not belong to Application {request.ApplicationId}"); } _auditService.StartTracking(UserAction.RemoveAppealFile, request.UserId, request.UserName); _auditService.AuditDelete(upload); _appealFileRepository.Remove(upload.Id); _auditService.Save(); return(Unit.Value); }