Skip to content

Commit

Permalink
add async Task<ResponseData> AsResponseData
Browse files Browse the repository at this point in the history
  • Loading branch information
witskeeper committed Sep 24, 2023
1 parent 1201bdb commit 6e1439f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/AspNetCore/ResponseDataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ public static ResponseData<TData> AsResponseData<TData>(this TData data, bool su
return new ResponseData<TData>(data: data, success: success, message: message, code: code, errorData: errorData);
}

public static async Task<ResponseData> AsResponseData(this Task task, bool success = true, string message = "", int code = 0, IEnumerable<object>? errorData = null)
{
await task;
return new ResponseData(success: success, message: message, code: code, errorData: errorData);
}


public static async Task<ResponseData<TData>> AsResponseData<TData>(this Task<TData> data, bool success = true, string message = "", int code = 0, IEnumerable<object>? errorData = null)
{
return new ResponseData<TData>(data: await data, success: success, message: message, code: code, errorData: errorData);
Expand Down

0 comments on commit 6e1439f

Please sign in to comment.