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 ResultBoolDto : ResultDto
    {
        [JsonPropertyName("value")]
        public bool Value { get; set; }


        public ResultBoolDto(bool value) : this()
        {
            Value = value;
        }

        public ResultBoolDto() : base(new List<IError>())
        {
            Value = false;
        }
        public ResultBoolDto(CodeException[] exceptions) : base(exceptions.Select(x => new ErrorMessageDto(x)))
        {
        }

        public ResultBoolDto(Exception exception) : base( new []{ exception is CodeException codeException ? new ErrorMessageDto(codeException) : new ErrorMessageDto(exception, -1)})
        {
        }

        public override object GetValue()
        {
            return Value;
        }
        public bool GetValueAs()
        {
            return Value;
        }
    }
}
