using System.Text.Json.Serialization;
using e_suite.API.Common.extensions;
using e_suite.Database.Core.Extensions;
using eSuite.Core.Miscellaneous;

namespace e_suite.API.Common.models;

public class EditFormInstance
{
    public EditFormInstance()
    {

    }

    public EditFormInstance(ReadFormInstance readFormInstance)
    {
        FormInstanceId = readFormInstance.ToGeneralIdRef()!;
        TemplateId = readFormInstance.TemplateId;
        Version = readFormInstance.Version;
        foreach (var values in readFormInstance.CustomFieldValues)
        {
            CustomFieldValues.Add(values.DeepClone());
        }
    }

    [JsonPropertyName("formInstanceId")]
    public GeneralIdRef FormInstanceId { get; set; } = null!;

    [JsonPropertyName("templateId")]
    public GeneralIdRef TemplateId { get; set; } = null!;

    [JsonPropertyName("version")]
    public long Version { get; set; }

    [JsonPropertyName("customFieldValues")]
    public List<CustomFieldValues> CustomFieldValues { get; set; } = [];
}