using AyCode.Core.Serializers.Attributes;
using AyCode.Core.Serializers.Toons;
using FruitBank.Common.Interfaces;
using LinqToDB.Mapping;
using Mango.Nop.Core.Dtos;
using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Interfaces;
using Newtonsoft.Json;
using Nop.Core.Domain.Catalog;
using Nop.Core.Domain.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FruitBank.Common.Entities;

namespace FruitBank.Common.Dtos
{
    [AcBinarySerializable(false, true, false, true, false, false)]
    [LinqToDB.Mapping.Table(Name = nameof(StockQuantityHistory))]
    [System.ComponentModel.DataAnnotations.Schema.Table(nameof(StockQuantityHistory))]
    [ToonDescription("Stock quantity history with net weight adjustments", TypeRelation = ToonTypeRelation.DtoOf, RelatedTypes = [typeof(StockQuantityHistory)])]
    public class StockQuantityHistoryDto : MgStockQuantityHistoryDto<ProductDto>, IStockQuantityHistoryDto
    {
        [NotColumn, NotMapped, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
        [ToonDescription(BusinessRule = "get => StockQuantityHistoryExt?.StockQuantityHistoryId")]
        public int? StockQuantityHistoryId
        {
            get => StockQuantityHistoryExt?.StockQuantityHistoryId;
            set => StockQuantityHistoryExt!.StockQuantityHistoryId = value!.Value;
        }

        [NotColumn, NotMapped, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
        [ToonDescription(BusinessRule = "get => StockQuantityHistoryExt?.NetWeightAdjustment")]
        public double? NetWeightAdjustment
        {
            get => StockQuantityHistoryExt?.NetWeightAdjustment;
            set => StockQuantityHistoryExt!.NetWeightAdjustment = value;
        }

        [NotColumn, NotMapped, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
        [ToonDescription(BusinessRule = "get => StockQuantityHistoryExt?.NetWeight")]
        public double? NetWeight
        {
            get => StockQuantityHistoryExt?.NetWeight;
            set => StockQuantityHistoryExt!.NetWeight = value;
        }

        [NotColumn, NotMapped, JsonIgnore, System.Text.Json.Serialization.JsonIgnore]
        [ToonDescription(Purpose = "Status flag", BusinessRule = "get => StockQuantityHistoryExt?.IsInconsistent ?? false")]
        public bool IsInconsistent
        {
            get => StockQuantityHistoryExt?.IsInconsistent ?? false;
            set => StockQuantityHistoryExt!.IsInconsistent = value;
        }

        [Association(ThisKey = nameof(Id), OtherKey = nameof(StockQuantityHistoryExt.StockQuantityHistoryId), CanBeNull = true)]
        public StockQuantityHistoryExt? StockQuantityHistoryExt { get; set; }
    }
}
