using AyCode.Entities.Locations;
using AyCode.Interfaces.TimeStampInfo;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TIAM.Resources;

namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
{
    public class TransferWizardModel
    {
        public Guid Id { get; set; }

        //[Required(ErrorMessage = "The Username value should be specified.")]
        //[Required(ErrorMessage = "The destination address should be specified.")]
        [Destination(ErrorMessage = "The destination value is invalid.")]
        [DataType("TransferDestination")]
        [Display(Name = ResourceKeys.Destination, ResourceType = typeof(TIAMResources))]
        public string? Destination { get; set; }

        //[Required(ErrorMessage = "The Username value should be specified.")]
        //[Required(ErrorMessage = "The pickup address should be specified.")]
        [DataType("TransferDestination")]
        [Display(Name = ResourceKeys.PickupAddress, ResourceType = typeof(TIAMResources))]
        public string? PickupAddress { get; set; }

        [Required(ErrorMessage = "The pickup time should be specified.")]
        [DataType(DataType.Date)]
        [Display(Name = ResourceKeys.PickupTime, ResourceType = typeof(TIAMResources))]
        public DateTime TripDate { get; set; } = DateTime.UtcNow.AddDays(2);

        [Required(ErrorMessage = "The amount of passengers should be specified.")]
        [DataType("Int")]
        [Display(Name = ResourceKeys.NumberOfPassengers, ResourceType = typeof(TIAMResources))]
        public int NumberOfPassengers { get; set; } = 1;

        //full name
        [Required(ErrorMessage = "The full name should be specified.")]
        [DataType(DataType.Text)]
        [Display(Name = ResourceKeys.FullName, ResourceType = typeof(TIAMResources))]
        public string? FullName { get; set; }

        //phone number
        [Required(ErrorMessage = "The phone number should be specified.")]
        [DataType(DataType.PhoneNumber)]
        [Display(Name = ResourceKeys.PhoneNumber, ResourceType = typeof(TIAMResources))]
        public string? PhoneNumber { get; set; }

        //email address
        [Required(ErrorMessage = "The email address should be specified.")]
        [DataType(DataType.EmailAddress)]
        [Display(Name = ResourceKeys.EmailAddress, ResourceType = typeof(TIAMResources))]
        public string? EmailAddress { get; set; }

        [DataType("Price")]
        [Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
        public double? Price { get; set;}

        [DataType("Driver")]
        [Display(Name = ResourceKeys.Driver, ResourceType = typeof(TIAMResources))]
        public DriverModel Driver { get; set; }





        public TransferWizardModel() { }
        public TransferWizardModel(string destination, string pickupAddress) : this(Guid.NewGuid(), destination, pickupAddress) { }
        public TransferWizardModel(Guid id, string destination, string pickupAddress) {
            Destination = destination;
            PickupAddress = pickupAddress;
        }

        public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, fullName, phoneNumber, emailAddress) { }
       

        public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress)
        {
            Id = id;
            Destination = destination;
            PickupAddress = pickupAddress;
            TripDate = tripDate;
            NumberOfPassengers = numberOfPassengers;
            FullName = fullName;
            PhoneNumber = phoneNumber;
            EmailAddress = emailAddress;
        }

        public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress, DriverModel driver) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, fullName, phoneNumber, emailAddress, driver) { }


        public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress, DriverModel driver)
        {
            Id = id;
            Destination = destination;
            PickupAddress = pickupAddress;
            TripDate = tripDate;
            NumberOfPassengers = numberOfPassengers;
            FullName = fullName;
            PhoneNumber = phoneNumber;
            EmailAddress = emailAddress;
            Driver = driver;
        }


    }
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
    public class DestinationAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            return true;
        }
    }
}
