ResultBoolDto.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.Json.Serialization;
  5. using Quadarax.Foundation.Core.Exceptions;
  6. namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto
  7. {
  8. public class ResultBoolDto : ResultDto
  9. {
  10. [JsonPropertyName("value")]
  11. public bool Value { get; set; }
  12. public ResultBoolDto(bool value) : this()
  13. {
  14. Value = value;
  15. }
  16. public ResultBoolDto() : base(new List<IError>())
  17. {
  18. Value = false;
  19. }
  20. public ResultBoolDto(CodeException[] exceptions) : base(exceptions.Select(x => new ErrorMessageDto(x)))
  21. {
  22. }
  23. public ResultBoolDto(Exception exception) : base( new []{ exception is CodeException codeException ? new ErrorMessageDto(codeException) : new ErrorMessageDto(exception, -1)})
  24. {
  25. }
  26. public override object GetValue()
  27. {
  28. return Value;
  29. }
  30. public bool GetValueAs()
  31. {
  32. return Value;
  33. }
  34. }
  35. }