using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;

namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems;

public class FindAccountRequest
{
    [Required, NotNull, StringLength(maximumLength: 200, MinimumLength = 4, ErrorMessage = "Login Id or Email address or Mobile number must be between 4 and 100 characters.")]
    public string AccountId { get; set; }
}

public class LoginRequest
{
    [Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 4, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
    public string LoginId { get; set; }

    [Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
    public string Password { get; set; }

    public string AppId { get; set; }

    [Required, NotNull, StringLength(maximumLength: 8, MinimumLength = 5, ErrorMessage = "Version must be 5 and 8 digits (Example: 0.0.0 or 99.99.99)")]
    public string AppVersion { get; set; }

    public bool AttendanceLogin { get; set; }
    public string HostName { get; set; }
    public string IpAddress { get; set; }
    public string MacAddress { get; set; }
    public string LoginRemarks { get; set; }
}


public class OtpValidationRequest
{
    public int UserId { get; set; }

    public EnumAuthenticationMethod AuthMethod { get; set; }

    [Required, NotNull, StringLength(6, MinimumLength = 6, ErrorMessage = "Otp must be 6 digit number.")]
    public string OtpCode { get; set; }
}

public class ByUserIdRequest
{
    public int UserId { get; set; }
}

public class SendPasswordRequest
{
    [Required, NotNull, StringLength(maximumLength: 300, MinimumLength = 1, ErrorMessage = "User Id is required.")]
    public string UserId { get; set; }
    public string MobileNo { get; set; }
    public string EmailAddress { get; set; }
}

public class UserUnlockRequest : ByUserIdRequest
{
    [Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Login Id must be between 1 and 30 characters.")]
    public string LoginId { get; set; }
}

public class ResetPasswordRequest : ByUserIdRequest
{
    [Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
    public string Password { get; set; }

    [Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Confirm Password must be between 1 and 30 characters.")]
    public string ConfirmPassword { get; set; }
}

public class PasswordChangeRequest : ResetPasswordRequest
{
    [Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Old Password must be between 1 and 30 characters.")]
    public string OldPassword { get; set; }
}

public class LogoutRequest
{
    public int LogId { get; set; }
    public bool AttendanceLogout { get; set; }
    public string IpAddress { get; set; }
    public string MacAddress { get; set; }
    public string HostName { get; set; }
    public string LogoutRemarks { get; set; }
}

public class UserThemeRequest
{
    [Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Menu Layout must be between 1 to 15 characters.")]
    public string MenuLayout { get; set; }

    [Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Theme Name must be between 1 to 15 characters.")]
    public string ThemeName { get; set; }

    [Required, NotNull, StringLength(10, MinimumLength = 1, ErrorMessage = "Scheme Name must be between 1 to 10 characters.")]
    public string SchemeName { get; set; }
}

public class UserRequestBase
{
    [Required, NotNull, StringLength(30, MinimumLength = 3, ErrorMessage = "Login Id must be between 3 to 30 characters.")]
    public string LoginId { get; set; }

    [Required, NotNull, StringLength(75, MinimumLength = 3, ErrorMessage = "User Name must be between 3 to 75 characters.")]
    public string UserName { get; set; }

    [Required, NotNull, StringLength(50, MinimumLength = 0, ErrorMessage = "Designation must be between 0 to 50 characters.")]
    public string Designation { get; set; }

    [StringLength(15, MinimumLength = 11, ErrorMessage = "Mobile number must be 11 characters.")]
    [RegularExpression(@"^[01]{2}[123456789]{1}[0-9]{8}$", ErrorMessage = "Mobile number is invalid.")]
    public string MobileNo { get; set; }

    [Required, NotNull, StringLength(100, MinimumLength = 5, ErrorMessage = "Email address must be between 5 to 100 characters.")]
    [RegularExpression(@"^(([a-zA-Z0-9_\-\.]+)\@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$", ErrorMessage = "Email address is invalid.")]
    public string EmailAddress { get; set; } = string.Empty;
    public bool AuthReqAtlogin { get; set; }
    public bool NeverExpire { get; set; }
    public bool DbOnStartup { get; set; }
    public bool DisallowMultiLogin { get; set; }
    public EnumStatus Status { get; set; }
    public short SeqId { get; set; }
    public bool ViewToAll { get; set; }
    public bool CanUseAttendanceSystem { get; set; }
    public EnumAuthenticationMethod AuthMethod { get; set; }
    public EnumAccessStatus AccessStatus { get; set; }
    public List<int> GroupIds { get; set; }
}

public class UserRequest : UserRequestBase
{
    [Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
    public int UserId { get; set; }

    public string AuthKey { get; set; }
}

public class NewUserRequest : UserRequestBase
{
    public int? EmployeeId { get; set; }
    public string EmployeeCode { get; set; }

    [Required, NotNull, StringLength(30, MinimumLength = 1, ErrorMessage = "User Name must be between 1 to 30 characters.")]
    public string Password { get; set; }
}

public class UserSearchRequest : ValueStatusAndPageAndSortSearchRequest
{
    public bool CheckOwner { get; set; }
}

public class ForceUserLogoutRequest
{
    public List<int> UserIds { get; set; }
}

public class ByUserAttributesRequest : ByUserIdRequest
{
    [Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
    public int ClientType { get; set; }
}

public class UpdateMyInfoRequest
{
    [Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Employee Id must be 1 to 2147483647")]
    public int EmployeeId { get; set; }

    [NotNull, StringLength(120, MinimumLength = 0, ErrorMessage = "Address be between 0 to 120 characters.")]
    public string Address { get; set; }

    public string ContactNo { get; set; }
}

public class UserAttributesRequest
{
    [Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user")]
    public int UserId { get; set; }

    [Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
    public int ClientType { get; set; }
    public List<string> UkIds { get; set; }
}
public class AccessLogSearchRequest
{
    public int AccessType { get; set; }
    public string LoginId { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
}

public class ByTeamSpaceAndBasicUserRequest
{
    public int TeamSpaceId { get; set; }
    public int ProjectId { get; set; }
}

public class BasicUserByTeamSpaceRequest : ByTeamSpaceAndBasicUserRequest
{
    public int UserId { get; set; }
}

public class BasicUserSearchRequest : BasicUserByTeamSpaceRequest
{
    public bool ApplyFilter { get; set; }
}

public class UserLimitAuthorizeRequest
{
    [Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
    public int UserId { get; set; }

    public decimal MaxAuthorizeAmount { get; set; }
}

public class PayslipRequest
{
    [Required, NotNull]
    public DateTime YearMonth { get; set; }
}


public class AppUserCreateRequest
{
    [Required(ErrorMessage = "Login ID is required.")]
    [MaxLength(100, ErrorMessage = "Login ID cannot exceed 100 characters.")]
    public string LoginId { get; set; } = string.Empty;

    [Required(ErrorMessage = "Username is required.")]
    [MaxLength(150, ErrorMessage = "Username cannot exceed 150 characters.")]
    public string UserName { get; set; } = string.Empty;

    [Required]
    public int Status { get; set; } 

    [Required]
    public int AccessStatus { get; set; } 

    [Phone(ErrorMessage = "Invalid mobile number format.")]
    [MaxLength(20, ErrorMessage = "Mobile number cannot exceed 20 characters.")]
    public string? MobileNo { get; set; }

    [Required(ErrorMessage = "Email address is required.")]
    [EmailAddress(ErrorMessage = "Invalid email address format.")]
    [MaxLength(200, ErrorMessage = "Email address cannot exceed 200 characters.")]
    public string EmailAddress { get; set; } = string.Empty;

    public int IsLocked { get; set; } 

    [Required(ErrorMessage = "Password is required.")]
    [MaxLength(500, ErrorMessage = "Password hash length cannot exceed 500 characters.")]
    public string Password { get; set; } = string.Empty;

    public int? UserPlatformId { get; set; }

    public int? UserRoleType { get; set; }

    [MaxLength(10,ErrorMessage = "EmployeeNumber hash length cannot exceed 10 characters")]
    public string? EmployeeNumber { get; set; }
}
