using Register_office.BaseClasses;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Register_office.Model;

public partial class ReferenceNumericValue : IUnionId
{
	public object GetId() => ReferenceValueId;

	public int ReferenceValueId { get; set; }

    public decimal? MinValue { get; set; }

    public decimal? MaxValue { get; set; }

    public int UnitId { get; set; }

    public virtual ReferenceValue ReferenceValue { get; set; } = null!;

    public virtual Unit Unit { get; set; } = null!;
}

internal class ReferenceNumericValueWrapper
{
	[Display(Name = "hide")]
	public int ReferenceValueId { get; set; }

	[Display(Name = "Мин.")]
	public decimal? MinValue { get; set; }

	[Display(Name = "Макс.")]
	public decimal? MaxValue { get; set; }

	[Display(Name = "hide")]
	public int UnitId { get; set; }

	[Display(Name = "Единица изм.")]
	public string UnitName { get; set; } = null!;

	public ReferenceNumericValueWrapper(ReferenceNumericValue src)
	{
		ReferenceValueId = src.ReferenceValueId;
		MinValue = src.MinValue;
		MaxValue = src.MaxValue;
		UnitId = src.UnitId;
		UnitName = src.Unit.Name;
	}

	internal static List<ReferenceNumericValueWrapper> ToList(List<ReferenceNumericValue> src)
	{
		List<ReferenceNumericValueWrapper> res = [];

		foreach (ReferenceNumericValue lst in src)
		{
			res.Add(new ReferenceNumericValueWrapper(lst));
		}

		return res;
	}
}
