using System;
using System.Windows.Forms;
using SepehrFlightApiSampleClient.Availability.WebApi;
using RequestModel = Sepehr.ApiGateway.Partners.Contracts.Flight.Availability.V17.ActiveRoutes.RequestModel;

namespace SepehrFlightApiSampleClient.Availability.WinForms.ActiveRoutes
{
    public partial class ActiveRoutesForm : Form
    {
        private readonly MainForm _mainForm;

        public ActiveRoutesForm(MainForm mainForm)
        {
            _mainForm = mainForm;
            InitializeComponent();

            gridActiveRoutes.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }

        private void btnGetActiveRoutes_Click(object sender, EventArgs e)
        {
            var request = new RequestModel.Request
            {
                UserName = _mainForm.txtUsername.Text,
                Password = _mainForm.txtPassword.Text,
                FetchSupplierWebserviceFlights = chkFetchSupplierWebserviceFlights.Checked,
            };

            var charterResponse = GetActiveRoutesApi.Post(_mainForm.txtUrl.Text, request);
            gridActiveRoutes.DataSource = charterResponse.ActiveRouteList;
        }
    }
}
