Example #1
0
 public static int?GetFirstErrorCode(this CommandResult commandResult)
 {
     return(commandResult.Errors.FirstOrDefault()?.Code);
 }
Example #2
0
 public static int GetStatusCode(this CommandResult commandResult)
 {
     return(commandResult.Succeeded ? (int)HttpStatusCode.OK : (commandResult.GetFirstErrorCode() ?? (int)HttpStatusCode.InternalServerError));
 }
Example #3
0
 public static object GetData(this CommandResult commandResult)
 {
     return(commandResult.Succeeded ? (commandResult.Data != null ? commandResult.Data : new { message = "Successfully" }) : new { errorMessage = commandResult.Errors.FirstOrDefault()?.Description });
 }
Example #4
0
 public static string GetFirstErrorMessage(this CommandResult commandResult)
 {
     return(commandResult.Errors.FirstOrDefault()?.Description);
 }