Erweitere ThenAsync Methoden in DTOExtensions um asynchrone Success-Funktionalität.
This commit is contained in:
parent
f170a4dd34
commit
f7a5d4fc28
@ -68,23 +68,45 @@ namespace DigitalData.Core.DTO
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<I>(this Result result, Func<Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static I Then<T, I>(this DataResult<T> result, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this DataResult<T> result, Func<T, Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
Result result = await tResult;
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
Result result = await tResult;
|
||||
return result.IsSuccess ? await SuccessAsync() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
DataResult<T> result = await tResult;
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, Task<I>> SuccessAsync, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
DataResult<T> result = await tResult;
|
||||
return result.IsSuccess ? await SuccessAsync(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static string Join<T>(this IEnumerable<T> values, string start = "", string seperator = ". ", string end = ".")
|
||||
=> new StringBuilder(start).Append(string.Join(seperator, values)).Append(end).ToString();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user