using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using e_suite.Database.Core.Tables.UserManager;

namespace e_suite.API.Common.models;

public class UserProfile
{
    [JsonPropertyName("firstName")]
    [Display(Name = "First Name")]
    public string FirstName { get; set; } = string.Empty;
    
    [JsonPropertyName("middleNames")]
    [Display(Name = "Middle Name(s)")]
    public string MiddleNames { get; set; } = string.Empty;
    
    [JsonPropertyName("lastName")]
    [Display(Name = "Last Name")]
    public string LastName { get; set; } = string.Empty;

    [JsonPropertyName("email")]
    [Required]
    [Display(Name = "E-Mail")]
    public string Email { get; set; } = string.Empty;

    [JsonPropertyName("password")]
    [Display(Name = "Password")]
    public string Password { get; set; } = string.Empty;

    [JsonPropertyName("usingTwoFactorAuthentication")]
    [Required]
    public bool UsingTwoFactorAuthentication { get; set; }

    [JsonPropertyName("created")]
    public DateTimeOffset Created { get; set; }

    [JsonPropertyName("twoFactorAuthenticationSettings")]
    public TwoFactorAuthenticationSettings TwoFactorAuthenticationSettings { get; set; } = null!;

    [JsonPropertyName("securityCode")]
    public string SecurityCode { get; set; } = null!;

    [JsonPropertyName("domainSsoProviderId")]

    public long? DomainSsoProviderId { get; set; } = null;

    [JsonPropertyName("ssoProviderId")]

    public long? SsoProviderId { get; set; } = null;

    [JsonPropertyName("ssoSubject")]

    public string SsoSubject { get; set; } = string.Empty;

    public Dictionary<long, string> SsoProviders { get; set; } = null!;

    [JsonPropertyName("preferredLocale")]
    public string PreferredLocale { get; set; } = string.Empty;
}


public class UpdatedUserProfile
{
    [JsonPropertyName("firstName")]
    public string FirstName { get; set; } = string.Empty;

    [JsonPropertyName("middleNames")]
    public string MiddleNames { get; set; } = string.Empty;

    [JsonPropertyName("lastName")]
    public string LastName { get; set; } = string.Empty;

    [JsonPropertyName("email")]
    [Required]
    public string Email { get; set; } = string.Empty;

    [JsonPropertyName("password")]
    public string Password { get; set; } = string.Empty;

    [JsonPropertyName("usingTwoFactorAuthentication")]
    [Required]
    public bool UsingTwoFactorAuthentication { get; set; }

    [JsonPropertyName("securityCode")]
    public string SecurityCode { get; set; } = string.Empty;

    [JsonPropertyName("preferredLocale")]
    public string PreferredLocale { get; set; } = string.Empty;
}

[Patches(typeof(User))]
public class PatchUserProfile
{
    [JsonPropertyName("firstName")]
    [PatchMap(nameof(User.FirstName))]
    public string? FirstName { get; set; }

    [JsonPropertyName("middleNames")]
    [PatchMap(nameof(User.MiddleNames))]
    public string? MiddleNames { get; set; }

    [JsonPropertyName("lastName")]
    [PatchMap(nameof(User.LastName))]
    public string? LastName { get; set; }
    
    [JsonPropertyName("preferredLocale")]
    [PatchMap(nameof(User.PreferredLocale))]
    public string? PreferredLocale { get; set; }
}