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

namespace Register_office.Model;

public partial class Result : IUnionId
{
	public object GetId() => ResultId;

    public int ResultId { get; set; }

    public int ExaminationId { get; set; }

    public virtual ExaminationType Examination { get; set; } = null!;

    public virtual ICollection<ExaminationTypePrescription> ExaminationTypePrescriptions { get; set; } = new List<ExaminationTypePrescription>();

	public virtual NumericResult? NumericResult { get; set; }

	public virtual QualitativeResult? QualitativeResult { get; set; }
}

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

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

	[Display(Name = "Обследование")]
	public string Examination { get; set; } = null!;

	[Display(Name = "Результат")]
	public string Result { get; set; } = null!;

	public ResultWrapper(Result src)
	{
		ResultId = src.ResultId;
		ExaminationId = src.ExaminationId;
		Examination = src.Examination.Name;
		Result = src.NumericResult != null
			? src.NumericResult.Value + " " + src.NumericResult.Unit
			: (src.QualitativeResult?.Value == true ? "Положительный" : "Отрициательный");
	}

	internal static List<ResultWrapper> ToList(List<Result> src)
	{
		List<ResultWrapper> res = [];

		foreach (Result lst in src)
		{
			res.Add(new ResultWrapper(lst));
		}

		return res;
	}
}
