using System.Text.Json;
using System.Text.Json.Serialization;

namespace View_by_Distance.Date.Group.Models;

public class Configuration
{

    protected Property.Models.Configuration _PropertyConfiguration;
    public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;

    public bool ByCreateDateShortcut { init; get; }
    public bool ByDay { init; get; }
    public bool ByHash { init; get; }
    public bool BySeason { init; get; }
    public bool ByWeek { init; get; }
    public bool KeepFullPath { init; get; }

    [JsonConstructor]
    public Configuration(Property.Models.Configuration propertyConfiguration, bool byCreateDateShortcut, bool byDay, bool byHash, bool bySeason, bool byWeek, bool keepFullPath)
    {
        ByDay = byDay;
        ByHash = byHash;
        ByWeek = byWeek;
        BySeason = bySeason;
        KeepFullPath = keepFullPath;
        ByCreateDateShortcut = byCreateDateShortcut;
        _PropertyConfiguration = propertyConfiguration;
    }

    public override string ToString()
    {
        string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
        return result;
    }

    public void SetAndUpdate(Property.Models.Configuration configuration)
    {
        _PropertyConfiguration = configuration;
        _PropertyConfiguration.Update();
    }

}