using System.Windows.Forms;
using SepehrFlightApiSampleClient.Availability.WinForms.DateRange.ViewModels;

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

        public void SetFlightClass(FlightClass flightClassViewModel)
        {
            //adult
            var adultUserControl = new AdvancedFareUserControl();
            adultUserControl.Location = new System.Drawing.Point(6, 6);
            adultUserControl.Dock = DockStyle.Fill;

            adultUserControl.SetFare(
                flightClassViewModel.OnewayFare.Adult_Fare,
                flightClassViewModel.RoundtripFare_SameOrigin?.Adult_Fare,
                flightClassViewModel.RoundtripFare_OppositeOrigin?.Adult_Fare);

            tbgAdult.Controls.Clear();
            tbgAdult.Controls.Add(adultUserControl);

            //child
            var childUserControl = new AdvancedFareUserControl();
            childUserControl.Location = new System.Drawing.Point(6, 6);
            childUserControl.Dock = DockStyle.Fill;

            childUserControl.SetFare(
                flightClassViewModel.OnewayFare.Child_Fare,
                flightClassViewModel.RoundtripFare_SameOrigin?.Child_Fare,
                flightClassViewModel.RoundtripFare_OppositeOrigin?.Child_Fare);

            tbgChild.Controls.Clear();
            tbgChild.Controls.Add(childUserControl);

            //infant
            var infantUserControl = new AdvancedFareUserControl();
            infantUserControl.Location = new System.Drawing.Point(6, 6);
            infantUserControl.Dock = DockStyle.Fill;

            infantUserControl.SetFare(
                flightClassViewModel.OnewayFare.Infant_Fare,
                flightClassViewModel.RoundtripFare_SameOrigin?.Infant_Fare,
                flightClassViewModel.RoundtripFare_OppositeOrigin?.Infant_Fare);

            tbgInfant.Controls.Clear();
            tbgInfant.Controls.Add(infantUserControl);

            txtCancelationPolicy.Text = flightClassViewModel.CancelationPolicy;
        }
    }
}
