Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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())
 {
 }
Exemplo n.º 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));
Exemplo n.º 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));
Exemplo n.º 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);
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 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));
 }
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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);
Exemplo n.º 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));