diff options
Diffstat (limited to 'src/main.lib/DomainObjects/RenewResult.cs')
-rw-r--r-- | src/main.lib/DomainObjects/RenewResult.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.lib/DomainObjects/RenewResult.cs b/src/main.lib/DomainObjects/RenewResult.cs new file mode 100644 index 0000000..6d751b0 --- /dev/null +++ b/src/main.lib/DomainObjects/RenewResult.cs @@ -0,0 +1,35 @@ +using PKISharp.WACS.Extensions; +using System; + +namespace PKISharp.WACS.DomainObjects +{ + public class RenewResult + { + public DateTime Date { get; set; } + public bool Success { get; set; } + public string ErrorMessage { get; set; } + public string Thumbprint { get; set; } + + private RenewResult() + { + Date = DateTime.UtcNow; + } + + public RenewResult(CertificateInfo certificate) : this() + { + Success = true; + Thumbprint = certificate.Certificate.Thumbprint; + } + + public RenewResult(string error) : this() + { + Success = false; + ErrorMessage = error; + } + + public override string ToString() => $"{Date} " + + $"- {(Success ? "Success" : "Error")}" + + $"{(string.IsNullOrEmpty(Thumbprint) ? "" : $" - Thumbprint {Thumbprint}")}" + + $"{(string.IsNullOrEmpty(ErrorMessage) ? "" : $" - {ErrorMessage.ReplaceNewLines()}")}"; + } +} |