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 AgeTypeUserControl();
            adultUserControl.Location = new System.Drawing.Point(6, 6);
            adultUserControl.Dock = DockStyle.Fill;

            adultUserControl.SetData(
                flightClassViewModel.OnewayFare.Adult_Fare,
                flightClassViewModel.RoundtripFare_FromOrigin?.Adult_Fare,
                flightClassViewModel.RoundtripFare_FromDestination?.Adult_Fare,
                flightClassViewModel.AdultFreeBaggage);

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

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

            childUserControl.SetData(
                flightClassViewModel.OnewayFare.Child_Fare,
                flightClassViewModel.RoundtripFare_FromOrigin?.Child_Fare,
                flightClassViewModel.RoundtripFare_FromDestination?.Child_Fare,
                flightClassViewModel.ChildFreeBaggage);

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

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

            infantUserControl.SetData(
                flightClassViewModel.OnewayFare.Infant_Fare,
                flightClassViewModel.RoundtripFare_FromOrigin?.Infant_Fare,
                flightClassViewModel.RoundtripFare_FromDestination?.Infant_Fare,
                flightClassViewModel.InfantFreeBaggage);

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

            txtCancelationPolicy.Text = flightClassViewModel.CancelationPolicy;
        }
    }
}
