| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json.Serialization;
- using Quadarax.Foundation.Core.Exceptions;
- namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto
- {
- public class ResultValueDto<TDto> : ResultDto where TDto : IDto, new()
- {
- [JsonPropertyName("value")] public TDto Value { get; set; }
- public ResultValueDto(TDto value) : this()
- {
- Value = value;
- }
- public ResultValueDto() : base(new List<IError>())
- {
- Value = new TDto();
- }
- public ResultValueDto(CodeException[] exceptions) : base(exceptions.Select(x => new ErrorMessageDto(x)))
- {
- }
- public ResultValueDto(Exception exception) : base(new[]
- {
- exception is CodeException codeException
- ? new ErrorMessageDto(codeException)
- : new ErrorMessageDto(exception, -1)
- })
- {
- }
- public override object GetValue()
- {
- return Value;
- }
- public TDto GetValueAs()
- {
- return Value;
- }
- }
- public class ResultValueDto: ResultDto
- {
- [JsonPropertyName("value")]
- public object Value { get; set; }
- public ResultValueDto(object value) : this()
- {
- Value = value;
- }
- public ResultValueDto() : base(new List<IError>())
- {
- Value = null;
- }
- public ResultValueDto(CodeException[] exceptions) : base(exceptions.Select(x => new ErrorMessageDto(x)))
- {
- }
- public ResultValueDto(Exception exception) : base( new []{ exception is CodeException codeException ? new ErrorMessageDto(codeException) : new ErrorMessageDto(exception, -1)})
- {
- }
- public override object GetValue()
- {
- return Value;
- }
- public object GetValueAs()
- {
- return Value;
- }
- }
- }
|