Skip to content

Commit 194d23c

Browse files
jdramesardalis
andauthored
Add Result.Created void methods so that return Result type is implicitly handled. (#200)
* Created methods should use the passed value to correctly create to respective Result<T> response with the set status of ResultStatus.Created * Reverted changes in order to make use of the Void result * Added the created methods to the Result.Void class so that it can implicitly convert from the Value to the Result<T> with the Created status set. --------- Co-authored-by: Steve Smith <[email protected]>
1 parent 8de48b9 commit 194d23c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Ardalis.Result/Result.Void.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,30 @@ public static Result<T> Success<T>(T value, string successMessage)
4949
return new Result<T>(value, successMessage);
5050
}
5151

52+
/// <summary>
53+
/// Represents a successful operation that resulted in the creation of a new resource.
54+
/// Accepts a value as the result of the operation.
55+
/// </summary>
56+
/// <param name="value">Sets the Value property</param>
57+
/// <returns>A Result<typeparamref name="T"/></returns>
58+
public static Result<T> Created<T>(T value)
59+
{
60+
return Result<T>.Created(value);
61+
}
62+
63+
/// <summary>
64+
/// Represents a successful operation that resulted in the creation of a new resource.
65+
/// Accepts a value as the result of the operation.
66+
/// Accepts a location for the new resource.
67+
/// </summary>
68+
/// <param name="value">Sets the Value property</param>
69+
/// <param name="location">The location of the newly created resource</param>
70+
/// <returns>A Result<typeparamref name="T"/></returns>
71+
public static Result<T> Created<T>(T value, string location)
72+
{
73+
return Result<T>.Created(value, location);
74+
}
75+
5276
/// <summary>
5377
/// Represents an error that occurred during the execution of the service.
5478
/// Error messages may be provided and will be exposed via the Errors property.

0 commit comments

Comments
 (0)