Added Conditional OperationalResponse constructor.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-11-19 13:04:40 -07:00
parent f629834d6a
commit 03b9331a9a
11 changed files with 65 additions and 128 deletions

View File

@@ -9,7 +9,7 @@ namespace CarCareTracker.Models
}
public class OperationResponse: OperationResponseBase
{
public static OperationResponse Succeed(string message)
public static OperationResponse Succeed(string message = "")
{
return new OperationResponse { Success = true, Message = message };
}
@@ -21,5 +21,13 @@ namespace CarCareTracker.Models
}
return new OperationResponse { Success = false, Message = message};
}
public static OperationResponse Conditional(bool result, string successMessage = "", string errorMessage = "")
{
if (string.IsNullOrWhiteSpace(errorMessage))
{
errorMessage = StaticHelper.GenericErrorMessage;
}
return new OperationResponse { Success = result, Message = result ? successMessage : errorMessage };
}
}
}