Last active
December 20, 2015 19:39
-
-
Save feanz/6184813 to your computer and use it in GitHub Desktop.
Operation Status Object could be returned from persistence layer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DebuggerDisplay("Status: {Status}")] | |
public class OperationStatus | |
{ | |
public bool Status { get; set; } | |
public int RecordsAffected { get; set; } | |
public string Message { get; set; } | |
public Object OperationId { get; set; } | |
//Store simple string for exception message to avoid any possible serialization issues | |
public string ExceptionMessage { get; set; } | |
public string ExceptionStackTrace { get; set; } | |
public string ExceptionInnerMessage { get; set; } | |
public string ExceptionInnerStackTrace { get; set; } | |
public static OperationStatus CreateFromException(string message, Exception exception) | |
{ | |
var opStatus = new OperationStatus | |
{ | |
Status = false, | |
Message = message, | |
OperationId = null | |
}; | |
if (exception != null) | |
{ | |
opStatus.ExceptionMessage = exception.Message; | |
opStatus.ExceptionStackTrace = exception.StackTrace; | |
opStatus.ExceptionInnerMessage = (exception.InnerException != null) ? exception.InnerException.Message : null; | |
opStatus.ExceptionInnerStackTrace = (exception.InnerException != null) ? exception.InnerException.StackTrace : null; | |
} | |
return opStatus; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment