コード例 #1
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                lblError.Text = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else
            {
                string flightName  = txtName.Text;
                int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                string airlinename = ddlAirLine.SelectedItem.Text;
                flightid = Request.QueryString["flightid"].ToString();
                Flight _flight = new Flight()
                {
                    ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                    {
                        Id = airlineid, Name = airlinename
                    }
                };
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                flightManager.UpdateFlight(_flight);

                lblError.Text = "Flight Updated";
            }
        }
コード例 #2
0
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                IFlightManager  flightManger = (IFlightManager)AirTravelManagerFactory.Create("Flight");
                PagedDataSource objPds       = new PagedDataSource();
                objPds.DataSource  = flightManger.GetFlights();
                objPds.AllowPaging = true;
                objPds.PageSize    = 3;

                objPds.CurrentPageIndex = CurrentPage;

                lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
                                      + objPds.PageCount.ToString();

                // Disable Prev or Next buttons if necessary
                commandPrevious.Enabled = !objPds.IsFirstPage;
                commandNext.Enabled     = !objPds.IsLastPage;

                dlFlight.DataSource = objPds;
                dlFlight.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                IFlightManager  flightManger = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                PagedDataSource objPds       = new PagedDataSource();
                List <Flight>   flights      = flightManger.GetFlights();
                if (flights.Count > 0)
                {
                    objPds.DataSource  = flights;
                    objPds.AllowPaging = true;
                    objPds.PageSize    = 3;

                    ctlAdminMaster.BuildPager(objPds);

                    dlFlight.DataSource = objPds;
                    dlFlight.DataBind();
                }
                else
                {
                    dlFlight.Visible = false;
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        public FlightController(IFlightManager manager, IFlightRepository flightRepository, IHostingEnvironment hostingEnvironment)
        {
            _manager = manager;

            _flightRepository       = flightRepository;
            this.hostingEnvironment = hostingEnvironment;
        }
コード例 #5
0
        public void BindData()
        {
            try
            {
                ddlAirLine.DataSource     = new AirLineManager().GetAirLines();
                ddlAirLine.DataTextField  = "Name";
                ddlAirLine.DataValueField = "Id";
                ddlAirLine.DataBind();

                flightid = Request.QueryString["flightid"].ToString();

                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                flight = flightManager.GetFlight(int.Parse(flightid));

                FlightClass flightclass = new FlightClass();


                txtName.Text             = flight.Name;
                ddlAirLine.SelectedValue = flight.AirlineForFlight.Id.ToString();
                GridView1.DataSource     = flight.GetClasses();
                GridView1.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
            catch (AirlineManagerException exc2)
            {
                throw exc2;
            }
        }
コード例 #6
0
        protected void dpFlightName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (dpFlightName.Text.Equals("None") == false)
            {
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                try
                {
                    Flight             flight        = flightManager.GetFlight(int.Parse(dpFlightName.SelectedValue));
                    List <TravelClass> flightClasses = new List <TravelClass>();

                    foreach (FlightClass fc in flight.GetClasses())
                    {
                        flightClasses.Add(fc.ClassInfo);
                    }

                    Repeater1.DataSource = flightClasses;
                    Repeater1.DataBind();
                }
                catch (FlightManagerException ex)
                {
                    ctlAdminMaster.ErrorMessage = ex.Message;
                }
            }
            else
            {
                ShowDefaultClasses();
            }
        }
コード例 #7
0
 public FlightPlansController(FlightContext flightContext, IFlightManager flightManager,
                              IFlightPlanManager flightPlanManager, IHttpClientFactory clientFactory)
 {
     _flightContext     = flightContext;
     _flightPlanManager = flightPlanManager;
     _flightManager     = flightManager;
     _clientFactory     = clientFactory;
 }
コード例 #8
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row          = GridView1.Rows[e.RowIndex];
                TextBox     txtNoOfSeats = (TextBox)row.FindControl("txtNoOfSeats");
                int         intNoOfSeats = Convert.ToInt32((txtNoOfSeats.Text.ToString()));

                if ((!int.TryParse(txtNoOfSeats.Text, out intNoOfSeats)) || (intNoOfSeats <= 0))
                {
                    ctlAdminMaster.ErrorMessage = "Seat count should be a positive number";
                    txtNoOfSeats.Focus();
                }
                else
                {
                    string txtClass = ((TextBox)row.FindControl("txtClass")).Text;

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = intNoOfSeats;

                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    flightManager.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    ctlAdminMaster.ErrorMessage = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                ctlAdminMaster.ErrorMessage = ex.Message;
            }
        }
コード例 #9
0
 public ScheduleController(ICityManager cityMgr, IFlightManager flightMgr, IAirlineManager airlineMgr, IScheduleManager schMgr, IRouteManager routeManager, IFlightCostManager fcostMgr)
 {
     this.airlineMgr   = airlineMgr;
     this.cityMgr      = cityMgr;
     this.schMgr       = schMgr;
     this.flightMgr    = flightMgr;
     this.routeManager = routeManager;
     this.fcostMgr     = fcostMgr;
 }
コード例 #10
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.Rows[e.RowIndex];

                if (((TextBox)row.FindControl("txtNoOfSeats")).Text.Length == 0)
                {
                    lblError.Text = "Seats Cannot be Empty";
                    ((TextBox)row.FindControl("txtNoOfSeats")).Focus();
                }
                else
                {
                    string txtClass     = ((TextBox)row.FindControl("txtClass")).Text;
                    int    txtNoOfSeats = Convert.ToInt32((((TextBox)row.FindControl("txtNoOfSeats")).Text.ToString()));

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = txtNoOfSeats;

                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    flightManager.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    lblError.Text = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
コード例 #11
0
        static void PseudoDIStartUp()
        {
            IFileHelper fileHelper = new FileHelper();

            PlaneRepository   = new PlaneRepository(fileHelper);
            AirportRepository = new AirportRepository(fileHelper);
            FlightManager     = new FlightManager(PlaneRepository, fileHelper);
            FlightManager.LoadFlights();
            FlightManager.RandomlyAssignPlanesToFlights();
            OrderRepository = new OrderRepository(fileHelper);
            OrderManager    = new OrderManager(FlightManager, OrderRepository);
        }
コード例 #12
0
        protected void dpAirlineName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                dpFlightName.Items.Clear();
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                List <Flight>  flightlist    = flightManager.GetFlightsForAirLine(int.Parse(dpAirlineName.SelectedValue));

                foreach (Flight c in flightlist)
                {
                    ListItem item = new ListItem(c.Name, c.ID.ToString());
                    dpFlightName.Items.Add(item);
                }
                dpFlightName.DataBind();
            }
            catch (FlightManagerException exc)
            {
                ctlAdminMaster.ErrorMessage = exc.Message;
            }
        }
コード例 #13
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtName.Text))
            {
                ctlAdminMaster.ErrorMessage = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else
            {
                if (!hdnName.Value.Equals(txtName.Text))
                {
                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };
                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    if (flightManager.UpdateFlight(_flight) > 0)
                    {
                        ctlAdminMaster.ErrorMessage = "Flight with the same name already exists in the target Airline";
                    }
                    else
                    {
                        ctlAdminMaster.ErrorMessage = "Flight Updated";
                        Response.Redirect("~/Admin/ManageFlights.aspx");
                    }
                }
                else
                {
                    ctlAdminMaster.ErrorMessage = "No changes made to the flight";
                }
            }
        }
コード例 #14
0
        protected void dpAirlineName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (dpAirlineName.Text.Equals("None") == false)
            {
                dpFlightName.Items.Clear();
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("Flight");
                try
                {
                    List <Flight> flightlist = flightManager.GetFlightsForAirLine(int.Parse(dpAirlineName.SelectedValue));

                    dpFlightName.Items.Add("None");
                    foreach (Flight c in flightlist)
                    {
                        ListItem item = new ListItem(c.Name, c.ID.ToString());
                        dpFlightName.Items.Add(item);
                    }
                    dpFlightName.DataBind();
                }
                catch (FlightManagerException ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
コード例 #15
0
 /// <summary>
 /// BookingManager ctor
 /// </summary>
 /// <param name="dbManager"></param>
 /// <param name="flightManager"></param>
 /// <param name="passengerManager"></param>
 public BookingManager(IDbManager dbManager, IFlightManager flightManager, IPassengerManager passengerManager)
 {
     this.dbManager        = dbManager;
     this.flightManager    = flightManager;
     this.passengerManager = passengerManager;
 }
コード例 #16
0
 public SearchController(IDataAccess dataAccess, IFlightManager flightManager, IFlightPriceCalculator priceCalculator)
 {
     _dataAccess      = dataAccess;
     _flightManager   = flightManager;
     _priceCalculator = priceCalculator;
 }
コード例 #17
0
 public FlightsController(IFlightManager flightManager)
 {
     this.flightManager = new FlightManager();
 }
コード例 #18
0
 public FlightsController(IFlightManager fm)
 {
     flightManager = fm;
 }
コード例 #19
0
 public FlightsController(IMemoryCache cache)
 {
     this.cache      = cache;
     flightsModel    = new FlightManager(this.cache);
     flihtPlansModel = new FlightPlanManager(this.cache);
 }
コード例 #20
0
 public SystemController(IFlightManager flightManager)
 {
     this.flightManager = flightManager;
 }
コード例 #21
0
 // dependency injection
 public FlightPlanController(IFlightManager manager, IMemoryCache cache)
 {
     flightManager = manager;
     memoryCache   = cache;
 }
コード例 #22
0
 public FlightDetailsModel(IFlightManager flightManager, IMapper mapper)
 {
     this.flightManager = flightManager;
     this.mapper        = mapper;
 }
コード例 #23
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                lblError.Text = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else if (ddlAirLine.Text.Equals("None") == true)
            {
                lblError.Text = "Select Airline Name";
                ddlAirLine.Focus();
            }
            else
            {
                string flightName  = txtName.Text;
                int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                string airlinename = ddlAirLine.SelectedItem.Text;
                Flight _flight     = new Flight()
                {
                    Name = flightName, AirlineForFlight = new Airline()
                    {
                        Id = airlineid, Name = airlinename
                    }
                };
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("Flight");

                try
                {
                    foreach (RepeaterItem item in dlClass.Items)
                    {
                        TextBox txtNoOfSeats = (TextBox)item.FindControl("txtNoOfSeats");
                        Label   lblClass     = (Label)item.FindControl("lblClass");

                        if (txtNoOfSeats.Text.Length == 0)
                        {
                            txtNoOfSeats.Focus();
                            lblError.Text = "No of Seats Cannot be Empty";
                            break;
                        }
                        else
                        {
                            if (txtNoOfSeats != null)
                            {
                                TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                                int         NoOfSeats   = int.Parse(txtNoOfSeats.Text);
                                FlightClass _class      = new FlightClass()
                                {
                                    ClassInfo = travelClass, NoOfSeats = NoOfSeats
                                };
                                _flight.AddClass(_class);
                            }
                        }
                    }
                    if (flightManager.AddFlight(_flight) == false)
                    {
                        lblError.Text = "Flight Name already exists";
                    }
                    else
                    {
                        lblError.Text = "Flight Added Successfully";
                    }
                }
                catch (FlightManagerException exc)
                {
                    throw exc;
                }
            }
        }
コード例 #24
0
 public FlightsController(IFlightManager iFlightManager)
 {
     flightManager = iFlightManager;
 }
コード例 #25
0
 public FlightsController(IFlightManager flightManager)
 {
     this.flightManager = flightManager;
 }
コード例 #26
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    ctlAdminMaster.ErrorMessage = "Flight Name Can't be Empty";
                    txtName.Focus();
                }
                else if (ddlAirLine.Text.Equals("None") == true)
                {
                    ctlAdminMaster.ErrorMessage = "Select Airline Name";
                    ddlAirLine.Focus();
                }
                else
                {
                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    Flight _flight     = new Flight()
                    {
                        Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };
                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                    bool           blnSeatsValid = true;

                    try
                    {
                        foreach (RepeaterItem item in dlClass.Items)
                        {
                            TextBox txtNoOfSeats     = (TextBox)item.FindControl("txtNoOfSeats");
                            Label   lblClass         = (Label)item.FindControl("lblClass");
                            int     intNumberOfSeats = 0;

                            if ((!int.TryParse(txtNoOfSeats.Text, out intNumberOfSeats)) || (intNumberOfSeats <= 0))
                            {
                                txtNoOfSeats.Focus();
                                ctlAdminMaster.ErrorMessage = "Seat count should be a positive number";
                                blnSeatsValid = false;
                                break;
                            }
                            else
                            {
                                if (txtNoOfSeats != null)
                                {
                                    TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                                    FlightClass _class      = new FlightClass()
                                    {
                                        ClassInfo = travelClass, NoOfSeats = intNumberOfSeats
                                    };
                                    _flight.AddClass(_class);
                                }
                            }
                        }
                        if (blnSeatsValid)
                        {
                            if (flightManager.AddFlight(_flight) == false)
                            {
                                ctlAdminMaster.ErrorMessage = "Flight Name already exists";
                            }
                            else
                            {
                                ctlAdminMaster.ErrorMessage = "Flight Added Successfully";
                            }
                        }
                    }
                    catch (FlightManagerException exc)
                    {
                        ctlAdminMaster.ErrorMessage = exc.Message;
                    }
                }
            }
        }
コード例 #27
0
 public PilotFlightsModel(IFlightManager flightManager, IMapper mapper)
 {
     this.flightManager = flightManager;
     this.mapper        = mapper;
 }
コード例 #28
0
 public FlightsController(IFlightManager flight)
 {
     this.flightControlManager = flight;
 }
コード例 #29
0
 public FlightController(IFlightManager flightmanager)
 {
     this.flightMgr = flightmanager;
 }
コード例 #30
0
 public FlightsController(IFlightManager flightManager, IFlightRepo flightRepo)
 {
     _flightManager = flightManager;
     _flightRepo    = flightRepo;
 }