[CHANGE] Adding accounts
This commit is contained in:
30
Manager.App/Models/System/ListResult.cs
Normal file
30
Manager.App/Models/System/ListResult.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using DotBased.Monads;
|
||||
|
||||
namespace Manager.App.Models.System;
|
||||
|
||||
public class ListResult<TResult> : Result<List<TResult>>
|
||||
{
|
||||
protected ListResult(List<TResult> result, int total) : base(result)
|
||||
{
|
||||
Total = total;
|
||||
}
|
||||
|
||||
protected ListResult(Exception exception) : base(exception)
|
||||
{
|
||||
Total = 0;
|
||||
}
|
||||
|
||||
protected ListResult(ResultError error) : base(error)
|
||||
{
|
||||
Total = 0;
|
||||
}
|
||||
|
||||
public int Total { get; set; }
|
||||
|
||||
public static implicit operator ListResult<TResult>(ResultError error) => new(error);
|
||||
public static implicit operator ListResult<TResult>(Exception exception) => new(exception);
|
||||
public static implicit operator ListResult<TResult>(List<TResult> result) => new(result, 0);
|
||||
public static implicit operator ListResult<TResult>(ListResultReturn<TResult> result) => new(result.List, result.Total);
|
||||
}
|
||||
|
||||
public record ListResultReturn<TResult>(List<TResult> List, int Total);
|
Reference in New Issue
Block a user