2020-04-12 20:01:46 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Seenginx.Models
|
|
|
|
|
{
|
|
|
|
|
public class Result<D>
|
|
|
|
|
{
|
|
|
|
|
public bool AllOk { get; private set; } = true;
|
|
|
|
|
public string ErrorMessage { get; private set; }
|
|
|
|
|
public Exception Exception { get; private set; } = null;
|
|
|
|
|
public D Data { get; private set; }
|
|
|
|
|
|
2020-05-02 18:57:42 +02:00
|
|
|
|
public Result() { }
|
|
|
|
|
public Result(D data)
|
|
|
|
|
{
|
|
|
|
|
Data = data;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 20:01:46 +02:00
|
|
|
|
public Result<D> Invalidate(string errorMessage, Exception exception = null)
|
|
|
|
|
{
|
|
|
|
|
AllOk = false;
|
|
|
|
|
ErrorMessage = errorMessage;
|
|
|
|
|
if (exception != null)
|
|
|
|
|
Exception = exception;
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetData(D data) => Data = data;
|
|
|
|
|
}
|
2020-07-06 18:01:01 +02:00
|
|
|
|
|
|
|
|
|
public class Result
|
|
|
|
|
{
|
|
|
|
|
public bool AllOk { get; private set; } = true;
|
|
|
|
|
public string ErrorMessage { get; private set; }
|
|
|
|
|
public Exception Exception { get; private set; } = null;
|
|
|
|
|
|
|
|
|
|
public Result Invalidate(string errorMessage, Exception exception = null)
|
|
|
|
|
{
|
|
|
|
|
AllOk = false;
|
|
|
|
|
ErrorMessage = errorMessage;
|
|
|
|
|
if (exception != null)
|
|
|
|
|
Exception = exception;
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-12 20:01:46 +02:00
|
|
|
|
}
|