using System;
using System.Windows.Forms;
using SepehrFlightApiSampleClient.Availability.WebApi.ActiveRoutes;
using RequestModel = Sepehr.ApiGateway.Partners.Contracts.Flight.Availability.V15.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 = true,
            };

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