using System.Collections.Generic;
using System.Windows.Forms;
using SepehrFlightApiSampleClient.Availability.WinForms.SearchByRouteAndDate.ViewModels;
using SepehrFlightApiSampleClient.BuiltinTypeExtensions;
// ReSharper disable InconsistentNaming

namespace SepehrFlightApiSampleClient.Availability.WinForms.SearchByRouteAndDate
{
    public partial class AgeTypeUserControl_Charter : UserControl
    {
        public AgeTypeUserControl_Charter()
        {
            InitializeComponent();
        }

        public void SetData(
            Fare fare,
            FreeBaggage freeBaggage)
        {
            gridFare.DataSource = GetItemList(fare);
            gridBaggage.DataSource = GetItemList(freeBaggage);
        }

        private static List<Item> GetItemList(Fare fare)
        {
            return new List<Item>()
            {
                new Item
                {
                    Desc = nameof(Fare.BaseFare),
                    Amount = fare.BaseFare.FormattedNumber(),
                },
                new Item
                {
                    Desc = nameof(Fare.TotalTax),
                    Amount = fare.TotalTax.FormattedNumber(),
                },
                new Item
                {
                    Desc = nameof(Fare.TotalFare),
                    Amount = fare.TotalFare.FormattedNumber(),
                },
                new Item
                {
                    Desc = nameof(Fare.Commission),
                    Amount = fare.Commission.FormattedNumber(),
                },
                new Item
                {
                    Desc = nameof(Fare.Markup),
                    Amount = fare.Markup.FormattedNumber(),
                },
                new Item
                {
                    Desc = nameof(Fare.Payable),
                    Amount = fare.Payable.FormattedNumber(),
                },
            };
        }

        private static List<Item> GetItemList(FreeBaggage freeBaggage)
        {
            return new List<Item>()
            {
                new Item
                {
                    Desc = nameof(FreeBaggage.CheckedBaggageQuantity),
                    Amount = freeBaggage.CheckedBaggageQuantity.ToString("N0"),
                },
                new Item
                {
                    Desc = nameof(FreeBaggage.CheckedBaggageTotalWeight),
                    Amount = freeBaggage.CheckedBaggageTotalWeight.ToString("N0"),
                },
                new Item
                {
                    Desc = nameof(FreeBaggage.HandBaggageQuantity),
                    Amount = freeBaggage.HandBaggageQuantity.ToString("N0"),
                },
                new Item
                {
                    Desc = nameof(FreeBaggage.HandBaggageTotalWeight),
                    Amount = freeBaggage.HandBaggageTotalWeight.ToString("N0"),
                }
            };
        }

        private class Item
        {
            public string Desc { get; set; }

            public string Amount { get; set; }
        }
    }
}
