public async Task <Unit> Handle(CertificateReprintRequest request, CancellationToken cancellationToken) { var certificate = await _certificateRepository.GetCertificate(request.CertificateReference, request.LastName, request.AchievementDate); if (certificate == null) { throw new NotFound(); } if (certificate.Status == CertificateStatus.Reprint) { return(Unit.Value); } if (CertificateStatus.CanRequestDuplicateCertificate(certificate.Status)) { certificate.Status = CertificateStatus.Reprint; await _certificateRepository.Update(certificate, request.Username, CertificateActions.Reprint); } else { throw new NotFound(); } return(Unit.Value); }
public async Task <Certificate> Handle(StaffCertificateDuplicateRequest request, CancellationToken cancellationToken) { var certificate = await _certificateRepository.GetCertificate(request.Id); if (CertificateStatus.CanRequestDuplicateCertificate(certificate.Status)) { certificate.Status = CertificateStatus.Reprint; await _certificateRepository.Update(certificate, request.Username, action : CertificateActions.Reprint); } return(certificate); }