using GMCabsDriverAssistant.Enums;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace GMCabsDriverAssistant.Models
{
    public class BookingDto
    {
        [JsonPropertyName("booking_id")]
        public Guid BookingId { get; set; }

        [JsonPropertyName("discount")]
        public decimal Discount { get; set; }

        [JsonPropertyName("start_address")]
        public string StartAddress { get; set; }

        [JsonPropertyName("start_suburb")]
        public string StartSuburb { get; set; }

        [JsonPropertyName("end_address")]
        public string EndAddress { get; set; }

        [JsonPropertyName("end_suburb")]
        public string EndSuburb { get; set; }

        [JsonPropertyName("future_booking")]
        public bool FutureBooking { get; set; }

        [JsonPropertyName("next_available")]
        public bool NextAvailable { get; set; }

        [JsonPropertyName("notes")]
        public string Notes { get; set; }

        [JsonPropertyName("taxi_type_id")]
        public int? TaxiTypeId { get; set; }

        [JsonPropertyName("fixed_amount")]
        public int? FixedAmount { get; set; }

        [JsonPropertyName("min_fare_amount")]
        public int? MinFareAmount { get; set; }

        [JsonPropertyName("provider_charge_fixed_fare")]
        public int? ProviderChargeFixedFare { get; set; }

        [JsonPropertyName("provider_charge_meter_fare")]
        public int? ProviderChargeMeterFare { get; set; }

        [JsonPropertyName("provider_charge_fixed_fare_preferred")]
        public int? ProviderChargeFixedFarePreferred { get; set; }

        [JsonPropertyName("provider_charge_meter_fare_preferred")]
        public int? ProviderChargeMeterFarePreferred { get; set; }

        [JsonPropertyName("pre_tip")]
        public int? PreTip { get; set; }

        [JsonPropertyName("start_time_local")]
        public int StartTimeLocal { get; set; }

        [JsonPropertyName("start_time_utc")]
        public int StartTimeUtc { get; set; }

        [JsonPropertyName("luggage_count")]
        public int LuggageCount { get; set; }

        [JsonPropertyName("passenger_count")]
        public int PassengerCount { get; set; }

        [JsonPropertyName("service_type_id")]
        public int ServiceTypeId { get; set; }

        [JsonPropertyName("passenger_phone_number")]
        public string PassengerPhoneNumber { get; set; }

        [JsonPropertyName("passenger_name")]
        public string PassengerName { get; set; }

        [JsonPropertyName("voucher_amount")]
        public decimal VoucherAmount { get; set; }

        [JsonPropertyName("latitude")]
        public double Latitude { get; set; }

        [JsonPropertyName("longitude")]
        public double Longitude { get; set; }

        [JsonPropertyName("distance")]
        public float Distance { get; set; }

        public string FormattedDistance
        {
            get => (Distance >= 1000) ? $"{Distance / 1000:0.##}k" : $"{(int)Distance}m";
        }

        [JsonPropertyName("estimate_fare")]
        public decimal EstimateFare { get; set; }

        [JsonPropertyName("is_corporate")]
        public bool IsCorporate { get; set; }

        [JsonPropertyName("in_hail")]
        public bool InHail { get; set; }

        [JsonPropertyName("payment_method_id")]
        public Guid? PaymentMethodId { get; set; }

        [JsonPropertyName("payment_method_verified")]
        public bool? PaymentMethodVerified { get; set; }

        [JsonPropertyName("rydo_stars")]
        public int RydoStars { get; set; }

        [JsonPropertyName("priority_driver")]
        public bool PriorityDriver { get; set; }

        [JsonPropertyName("end_latitude")]
        public double EndLatitude { get; set; }

        [JsonPropertyName("end_longitude")]
        public double EndLongitude { get; set; }

        [JsonPropertyName("start_latitude")]
        public double StartLatitude { get; set; }

        [JsonPropertyName("start_longitude")]
        public double StartLongitude { get; set; }

        [JsonPropertyName("payment_type")]
        public PaymentType PaymentType { get; set; }

        [JsonPropertyName("booking_type")]
        public BookingType BookingType { get; set; }

        [JsonPropertyName("pickup_time")]
        public int PickupTime { get; set; }

        [JsonPropertyName("fare_type")]
        public FareType FareType { get; set; }

        [JsonPropertyName("status_id")]
        public int StatusId { get; set; }

        [JsonPropertyName("status_code")]
        public string StatusCode { get; set; }

        [JsonPropertyName("delivered")]
        public bool Delivered { get; set; }

        [JsonPropertyName("ride_id")]
        public Guid? RideId { get; set; }

        [JsonPropertyName("fare_amount")]
        public int? FareAmount { get; set; }

        [JsonPropertyName("end_state")]
        public string EndState { get; set; }

        [JsonPropertyName("service_id")]
        public int ServiceId { get; set; }

        [JsonPropertyName("start_state")]
        public string StartState { get; set; }

        [JsonPropertyName("journey_distance")]
        public int JourneyDistance { get; set; }

        [JsonPropertyName("reward_points")]
        public int RewardPoints { get; set; }

        [JsonPropertyName("booking_fee")]
        public double BookingFee { get; set; }

        [JsonPropertyName("booking_fee_waived")]
        public bool BookingFeeWaived { get; set; }

        [JsonPropertyName("tip")]
        public int? Tip { get; set; }

        [JsonPropertyName("driver_number_plate")]
        public string DriverNumberPlate { get; set; }

        [JsonPropertyName("estimated_arrival_time")]
        public int EstimatedArrivalTime { get; set; }

        [JsonPropertyName("voucher_id")]
        public string VoucherId { get; set; }

        [JsonPropertyName("promotion_id")]
        public string PromotionId { get; set; }

        [JsonPropertyName("stored_cards_available")]
        public bool StoredCardsAvailable { get; set; }

        [JsonPropertyName("current_stop_number")]
        public int? CurrentStopNumber { get; set; }

        [JsonPropertyName("stopover_locations")]
        public IEnumerable<StopoverLocation> StopoverLocations { get; set; }

        public string FormattedPickUpTimeDateOnly
        {
            get
            {
                DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                dateTime = dateTime.AddSeconds(PickupTime).ToLocalTime();
                return dateTime.ToString("dd/MM/yyyy");
            }

        }
        public string FormattedPickUpTimeTimeOnly
        {
            get
            {
                DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                dateTime = dateTime.AddSeconds(PickupTime).ToLocalTime();
                return dateTime.ToString("HH:mm ttt");
            }

        }
        public string FormmattedPickUpDateTime
        {
            get
            {
                DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                dateTime = dateTime.AddSeconds(PickupTime).ToLocalTime();
                return dateTime.ToString("dd/MM/yyyy HH:mm:ss");
            }

        }
        public bool IsSeenBooking { get; set; }
    }
    public class StopoverLocation
    {

        [JsonPropertyName("latitude")]
        public decimal Latitude { get; set; }

        [JsonPropertyName("longitude")]
        public decimal Longitude { get; set; }

        [JsonPropertyName("address")]
        public string Address { get; set; }

        [JsonPropertyName("stop_number")]
        public decimal StopNumber { get; set; }
    }


}