|
@@ -1,52 +1,21 @@
|
|
|
-using System;
|
|
|
|
|
-using System.Collections.Generic;
|
|
|
|
|
-using System.Linq;
|
|
|
|
|
-using Quadarax.Foundation.Core.Exceptions;
|
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto
|
|
namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto
|
|
|
{
|
|
{
|
|
|
- public abstract class ResultDto : IDto, IResult
|
|
|
|
|
|
|
+ public abstract class ResultDto : Result, IDto
|
|
|
{
|
|
{
|
|
|
- /// <summary>
|
|
|
|
|
- /// <inheritdoc cref="IResult.IsSuccess"/>
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public bool IsSuccess => !Errors.Any();
|
|
|
|
|
- /// <summary>
|
|
|
|
|
- /// <inheritdoc cref="IResult.Errors"/>
|
|
|
|
|
- /// </summary>
|
|
|
|
|
- public IEnumerable<ErrorMessageDto> Errors { get; set; }
|
|
|
|
|
- //public IEnumerable<IError> Errors { get; set; }
|
|
|
|
|
-
|
|
|
|
|
- IEnumerable<IError> IResult.Errors => Errors;
|
|
|
|
|
|
|
|
|
|
|
|
+ protected ResultDto() : base() { }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultDto(IEnumerable<IError> errors) : base(isSuccess: false, errors) { }
|
|
|
|
|
+
|
|
|
|
|
+ public ResultDto(bool isSuccess, IEnumerable<IError>? errors) : base(isSuccess, errors) { }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// <inheritdoc cref="IResult.GetValue()"/>
|
|
/// <inheritdoc cref="IResult.GetValue()"/>
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
|
- public abstract object? GetValue();
|
|
|
|
|
-
|
|
|
|
|
- protected ResultDto(IEnumerable<IError> errors)
|
|
|
|
|
- {
|
|
|
|
|
- Errors = new List<ErrorMessageDto>(errors.Select(x=>(ErrorMessageDto) x));
|
|
|
|
|
- //Errors = new List<IError>(errors);
|
|
|
|
|
- }
|
|
|
|
|
- protected ResultDto()
|
|
|
|
|
- {
|
|
|
|
|
- Errors = new List<ErrorMessageDto>();
|
|
|
|
|
- }
|
|
|
|
|
- public AggregateException? ToAggregateException()
|
|
|
|
|
- {
|
|
|
|
|
- if (IsSuccess)
|
|
|
|
|
- return null;
|
|
|
|
|
- var errors = new List<Exception>();
|
|
|
|
|
- foreach (var e in Errors)
|
|
|
|
|
- {
|
|
|
|
|
- var addExc = new Exception(e.Message);
|
|
|
|
|
- addExc.SetCode(e.Code);
|
|
|
|
|
- errors.Add(addExc);
|
|
|
|
|
- }
|
|
|
|
|
- return new AggregateException(errors);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public new abstract object? GetValue();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|