Example #1
0
        // Aliases for DomainResult<TValue> extensions [PUBLIC, STATIC]

        #region Extensions of 'IDomainResult<T>' [STATIC, PUBLIC] -------------

        /// <summary>
        ///		Get 'success' status with a value. Gets converted to HTTP code 200 (Ok)
        /// </summary>
        /// <typeparam name="TValue"> The value type </typeparam>
        /// <param name="value"> The value to be returned </param>
        public static IDomainResult <TValue> Success <TValue>(TValue value) => DomainResult <TValue> .Success(value);
Example #2
0
 /// <summary>
 ///		Get 'not found' status. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="message"> Optional message </param>
 public static IDomainResult <TValue> NotFound <TValue>(string?message = null) => DomainResult <TValue> .NotFound(message);
Example #3
0
 /// <summary>
 ///		Get 'Unauthorized' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 403 (Forbidden)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="message"> Optional message </param>
 public static Task <IDomainResult <TValue> > UnauthorizedTask <TValue>(string?message = null) => DomainResult <TValue> .UnauthorizedTask(message);
Example #4
0
 /// <summary>
 ///		Get 'error' status. Gets be converted to HTTP code 400/422
 /// </summary>
 /// <param name="error"> Optional message </param>
 public static IDomainResult <TValue> Failed(string?error = null) => new DomainResult <TValue>(DomainResult.Failed(error));
Example #5
0
 /// <summary>
 ///		Get 'error' status with validation errors. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="validationResults"> Results of a validation request </param>
 public static IDomainResult <TValue> Failed <TValue>(IEnumerable <ValidationResult> validationResults) => DomainResult <TValue> .Failed(validationResults);
Example #6
0
 /// <summary>
 ///		Get 'not found' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="message"> Optional message </param>
 public static Task <IDomainResult <TValue> > NotFoundTask <TValue>(string?message = null) => DomainResult <TValue> .NotFoundTask(message);
Example #7
0
 /// <summary>
 ///     Convert to <see cref="IDomainResult{T}" /> (the domain operation result with a returned value)
 /// </summary>
 /// <typeparam name="T"> Value type of returned by the domain operation </typeparam>
 public static IDomainResult <T> To <T>(this IDomainResult domainResult)
 {
     return(DomainResult <T> .From(domainResult));
 }
Example #8
0
 /// <summary>
 ///		Get 'error' status. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="error"> Optional message </param>
 public static IDomainResult <TValue> Failed <TValue>(string?error = null) => DomainResult <TValue> .Failed(error);
Example #9
0
 /// <summary>
 ///		Get 'not found' status. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <param name="message"> Optional message </param>
 public static IDomainResult <TValue> NotFound(string?message = null) => new DomainResult <TValue>(DomainResult.NotFound(message));
Example #10
0
 /// <summary>
 ///		Get 'not found' status. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <param name="messages"> Custom messages </param>
 public static IDomainResult <TValue> NotFound(IEnumerable <string> messages) => new DomainResult <TValue>(DomainResult.NotFound(messages));
Example #11
0
 /// <summary>
 ///		Creates a new instance with 'success' status and a value
 /// </summary>
 /// <param name="value"> The value to be returned </param>
 protected DomainResult(TValue value)                            : this(value, DomainResult.Success())
 {
 }
Example #12
0
 /// <summary>
 ///		Get 'error' status with validation errors. Gets be converted to HTTP code 400/422
 /// </summary>
 /// <param name="validationResults"> Results of a validation request </param>
 public static IDomainResult <TValue> Failed(IEnumerable <ValidationResult> validationResults) => new DomainResult <TValue>(DomainResult.Failed(validationResults));
Example #13
0
 /// <summary>
 ///		Get 'error' status. Gets be converted to HTTP code 400/422
 /// </summary>
 /// <param name="errors"> Custom messages </param>
 public static IDomainResult <TValue> Failed(IEnumerable <string> errors) => new DomainResult <TValue>(DomainResult.Failed(errors));
Example #14
0
 /// <summary>
 ///		Get 'not found' status. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="messages"> Custom messages </param>
 public static IDomainResult <TValue> NotFound <TValue>(IEnumerable <string> messages) => DomainResult <TValue> .NotFound(messages);
Example #15
0
 /// <summary>
 ///     Convert to a <see cref="Task" /> of <see cref="IDomainResult{T}" /> (the domain operation result with a returned
 ///     value)
 /// </summary>
 /// <typeparam name="T"> Value type of returned by the domain operation </typeparam>
 public static async Task <IDomainResult <T> > To <T>(this Task <IDomainResult> domainResult)
 {
     return(DomainResult <T> .From(await domainResult));
 }
Example #16
0
 /// <summary>
 ///		Get 'Unauthorized' status. Gets converted to HTTP code 403 (Forbidden)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="message"> Optional message </param>
 public static IDomainResult <TValue> Unauthorized <TValue>(string?message = null) => DomainResult <TValue> .Unauthorized(message);
Example #17
0
 /// <summary>
 ///     Convert to a <see cref="IDomainResult{T}" /> with a new value type <typeparamref name="TNew"/>
 /// </summary>
 /// <typeparam name="TOld"> The old value type (converting from) </typeparam>
 /// <typeparam name="TNew"> The new value type (converting to) </typeparam>
 public static IDomainResult <TNew> To <TOld, TNew>(this IDomainResult <TOld> domainResult)
 {
     return(DomainResult <TNew> .From(domainResult));
 }
Example #18
0
 /// <summary>
 ///		Get 'error' status. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="errors"> Custom messages </param>
 public static IDomainResult <TValue> Failed <TValue>(IEnumerable <string> errors) => DomainResult <TValue> .Failed(errors);
Example #19
0
 /// <summary>
 ///     Convert to a <see cref="Task"/> of <see cref="IDomainResult{T}" /> with a new value type <typeparamref name="TNew"/>
 /// </summary>
 /// <typeparam name="TOld"> The old value type (converting from) </typeparam>
 /// <typeparam name="TNew"> The new value type (converting to) </typeparam>
 public static async Task <IDomainResult <TNew> > To <TOld, TNew>(this Task <IDomainResult <TOld> > domainResult)
 {
     return(DomainResult <TNew> .From(await domainResult));
 }
Example #20
0
 /// <summary>
 ///		Get 'success' status with a value (all wrapped in <see cref="Task{T}"/>).
 ///		Gets converted to HTTP code 200 (Ok)
 /// </summary>
 /// <typeparam name="TValue"> The value type </typeparam>
 /// <param name="value"> The value to be returned </param>
 public static Task <IDomainResult <TValue> > SuccessTask <TValue>(TValue value) => DomainResult <TValue> .SuccessTask(value);
Example #21
0
 /// <summary>
 ///		Get 'error' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="errors"> Custom messages </param>
 public static Task <IDomainResult <TValue> > FailedTask <TValue>(IEnumerable <string> errors) => DomainResult <TValue> .FailedTask(errors);
Example #22
0
 /// <summary>
 ///		Get 'not found' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 404 (NotFound)
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="messages"> Custom messages </param>
 public static Task <IDomainResult <TValue> > NotFoundTask <TValue>(IEnumerable <string> messages) => DomainResult <TValue> .NotFoundTask(messages);
Example #23
0
 /// <summary>
 ///		Get 'error' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="validationResults"> Results of a validation request </param>
 public static Task <IDomainResult <TValue> > FailedTask <TValue>(IEnumerable <ValidationResult> validationResults) => DomainResult <TValue> .FailedTask(validationResults);
Example #24
0
 /// <summary>
 ///		Get 'error' status wrapped in a <see cref="Task{T}"/>. Gets converted to HTTP code 400/422
 /// </summary>
 /// <typeparam name="TValue"> The expected value type if the operation was successful </typeparam>
 /// <param name="error"> Optional message </param>
 public static Task <IDomainResult <TValue> > FailedTask <TValue>(string?error = null) => DomainResult <TValue> .FailedTask(error);
Example #25
0
 /// <summary>
 ///		Get 'Unauthorized' status. Gets converted to HTTP code 403 (Forbidden)
 /// </summary>
 /// <param name="message"> Optional message </param>
 public static IDomainResult <TValue> Unauthorized(string?message = null) => new DomainResult <TValue>(DomainResult.Unauthorized(message));