mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using CarCareTracker.Helper;
|
|
|
|
namespace CarCareTracker.Models
|
|
{
|
|
public class OperationResponseBase
|
|
{
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; }
|
|
}
|
|
public class OperationResponse: OperationResponseBase
|
|
{
|
|
public static OperationResponse Succeed(string message = "")
|
|
{
|
|
return new OperationResponse { Success = true, Message = message };
|
|
}
|
|
public static OperationResponse Failed(string message = "")
|
|
{
|
|
if (string.IsNullOrWhiteSpace(message))
|
|
{
|
|
message = StaticHelper.GenericErrorMessage;
|
|
}
|
|
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 };
|
|
}
|
|
}
|
|
}
|