public async Task Load(AirportBusinessService dataServices, int?airportId) { if (airportId.HasValue) { Airport = await dataServices.GetAirport(airportId.Value); } }
/// Date Created: 08/Aug/2013 /// Created By: Josephine Gad /// (description) Delete vehicle type /// ------------------------------------------- //protected void uoListViewAirport_ItemCommand(object sender, System.Web.UI.WebControls.ListViewCommandEventArgs e) //{ // string strLogDescription; // string strFunction; // int index = GlobalCode.Field2Int(e.CommandArgument); // if (e.CommandName == "Delete") // { // //MaintenanceViewBLL.DeletePortAgent(index, GlobalCode.Field2String(Session["UserName"])); // ////Insert log audit trail (Gabriel Oquialda - 17/11/2011) // //strLogDescription = "Vehicle vendor branch deleted. (flagged as inactive)"; // //strFunction = "uoPortAgentList_ItemCommand"; // //DateTime currentDate = CommonFunctions.GetCurrentDateTime(); // //BLL.AuditTrailBLL.InsertLogAuditTrail(index, "", strLogDescription, strFunction, Path.GetFileName(Request.Path), // // CommonFunctions.GetDateTimeGMT(currentDate), DateTime.Now, GlobalCode.Field2String(Session["UserName"])); // BindVendorTypeList(1); // } //} /// <summary> /// Date Created: 05/Nov/2013 /// Created By: Josephine gad /// (description) Add Airport in ListView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void uoButtonPortAgentAirportAdd_Click(object sender, EventArgs e) { List <AirportDTO> listAirport = new List <AirportDTO>(); List <AirportDTO> ListPortAgentAirport = new List <AirportDTO>(); listAirport = GetAirportNotExist(0); ListPortAgentAirport = GetPortAgentAirport(0); listAirport.RemoveAll(a => listAirport.Exists(b => a.AirportIDString == uoDropDownListAirport.SelectedValue)); listAirport = listAirport.OrderBy(a => a.AirportNameString).ToList(); AirportDTO item = new AirportDTO(); item.AirportIDString = uoDropDownListAirport.SelectedValue; item.AirportNameString = uoDropDownListAirport.SelectedItem.Text; ListPortAgentAirport.Add(item); ListPortAgentAirport = ListPortAgentAirport.OrderBy(a => a.AirportNameString).ToList(); Session["PortAgentAirportNotExist"] = listAirport; Session["PortAgentAirport"] = ListPortAgentAirport; BindAirportList(0); BindPortAgentAirportList(0); }
public async Task <IHttpActionResult> CreateAirport(AirportDTO model) { var resultMessage = string.Empty; try { //TraceManager.StartMethodTrace(Traces.IndexStackFrameAsynController, "model: " + JsonConvert.SerializeObject(model)); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var request = DistributedServicesAutoMapper.Map <Domain.BO.Airport.AirportDTO>(model); AirportServices.CreateAirport(request); resultMessage = SharedLanguage.REQUEST_SUCCESSFUL; return(Ok(resultMessage)); } catch (Exception ex) { resultMessage = ""; //TraceManager.ExceptionErrorTrace(ex, Traces.IndexStackFrameAsynController); return(ResponseMessage(HttpHelper.GetHttpResponseErrorMessage(resultMessage))); } finally { //TraceManager.FinishMethodTrace(Traces.IndexStackFrameAsynController, "resultMessage: " + resultMessage); } }
/// <summary> /// Date Created: 05/Nov/2013 /// Created By: Josephine gad /// (description) Remove Airport in Service Provider /// </summary> protected void uoListViewAirport_ItemDeleting(object sender, ListViewDeleteEventArgs e) { HiddenField uoHiddenFieldAirportID = (HiddenField)uoListViewAirport.Items[e.ItemIndex].FindControl("uoHiddenFieldAirportID"); Label uoLabelAirportName = (Label)uoListViewAirport.Items[e.ItemIndex].FindControl("uoLabelAirportName"); List <AirportDTO> listAirport = new List <AirportDTO>(); List <AirportDTO> ListPortAgentAirport = new List <AirportDTO>(); listAirport = GetAirportNotExist(0); ListPortAgentAirport = GetPortAgentAirport(0); ListPortAgentAirport.RemoveAll(a => ListPortAgentAirport.Exists(b => a.AirportIDString == uoHiddenFieldAirportID.Value)); ListPortAgentAirport = ListPortAgentAirport.OrderBy(a => a.AirportNameString).ToList(); AirportDTO item = new AirportDTO(); item.AirportIDString = uoHiddenFieldAirportID.Value; item.AirportNameString = uoLabelAirportName.Text; listAirport.Add(item); Session["PortAgentAirportNotExist"] = listAirport; Session["PortAgentAirport"] = ListPortAgentAirport; BindAirportList(0); BindPortAgentAirportList(0); }
public List <AirportDTO> LoadDataAirport() { List <AirportDTO> list = new List <AirportDTO>(); using (var db = new TravelAirportContext()) { var query = from b in db.Airports orderby b.Name select b; foreach (var item in query) { AirportDTO p = new AirportDTO(); p.Name = item.Name; p.GPS = item.GPS; p.listAirplane = new List <AirplaneDTO>(); foreach (var airplaneitem in item.Airplanes) { AirplaneDTO airplane = new AirplaneDTO(); airplane.AirplaneId = airplaneitem.AirplaneId; airplane.FuelConsumption = airplaneitem.FuelConsumption; airplane.TakeoffEffort = airplaneitem.TakeoffEffort; airplane.Title = airplaneitem.Title; p.listAirplane.Add(airplane); } list.Add(p); } } return(list); }
public AirportDTO GetAirport(AirportDTO request) { var airportEntity = DomainAutoMapper.Map <Data.Entities.Airport>(request); var airport = AirportRepository.GetAirports(airportEntity).FirstOrDefault(); return(DomainAutoMapper.Map <AirportDTO>(airport)); }
/// <summary> /// Author: Josephine Gad /// Date Created: 04/Jul/2014 /// Description: Get Unassigned Airport based from session or listview /// </summary> private List <AirportDTO> GetAirportNotAssigned() { List <AirportDTO> listAirportNotAssigned = new List <AirportDTO>(); AirportDTO item; if (Session["HotelAirportBrandPop_AirportNotAssigned"] != null) { listAirportNotAssigned = (List <AirportDTO>)Session["HotelAirportBrandPop_AirportNotAssigned"]; } else { HiddenField hAirport; Label lAirport; for (int i = 0; i < uoListViewAirportNotAssigned.Items.Count; i++) { hAirport = (HiddenField)uoListViewAirportAssigned.Items[i].FindControl("uoHiddenFieldAirport"); lAirport = (Label)uoListViewAirportAssigned.Items[i].FindControl("uoLabelAirport"); item = new AirportDTO(); item.AirportIDString = hAirport.Value; item.AirportNameString = lAirport.Text; listAirportNotAssigned.Add(item); } Session["HotelAirportBrandPop_AirportNotAssigned"] = listAirportNotAssigned; } return(listAirportNotAssigned); }
public async Task <RoutePageVM> GetRoutePageViewModelAsync(string searchString, int pageIndex = 1) { List <RouteVM> ListRoutes = new List <RouteVM>(); // var movies = await _service.GetMoviesAsync(searchString, genre); var Routes = await _service.getAllRouteAsync(); var origin_name = ""; var destination_name = ""; Routes = await _service.SortAsync(Routes, ORDER_ENUM.ORIGIN_NAME, ORDER_ENUM.DESCENDING); foreach (var item in Routes) { AirportDTO origin_airport = await _airportService.getAirportAsync(item.Origin); AirportDTO des_airport = await _airportService.getAirportAsync(item.Destination); origin_name = origin_airport.AirportName; destination_name = des_airport.AirportName; RouteVM routeVM = new RouteVM(item.RouteId, origin_name, destination_name, item.Origin, item.Destination, item.Status, item.FlightTime.toString()); ListRoutes.Add(routeVM); } // if (searchString != null) // { // // Routes = await _service.getRouteByConditionsAsync(searchString, "", ""); // } // var genres = await _service.GetGenresAsync(); // var abc = _mapper.Map<IEnumerable<Route>, IEnumerable<RouteDTO>>(Routes); return(new RoutePageVM { Routes = PaginatedList <RouteVM> .Create(ListRoutes, pageIndex, pageSize) }); }
public async Task <List <AirportDTO> > GetAirports(string[] iataCodes) { string baseUrl = "https://places-dev.cteleport.com/airports/"; AirportDTO airport = null; List <AirportDTO> _airports = new List <AirportDTO>(); using (var client = new HttpClient()) { try { foreach (var iataCode in iataCodes) { HttpResponseMessage response = await client.GetAsync(baseUrl + iataCode); var json = response.Content.ReadAsStringAsync().Result; if (json.Any() && json != "Not Found") { airport = JsonConvert.DeserializeObject <AirportDTO>(json); _airports.Add(airport); } } return(_airports); } catch (HttpRequestException) { throw new HttpRequestException("Something happened, please try again later."); } } }
public static void Update(AirportDTO airport) { if (airport != null) { foreach (var plane in airport.Planes) { Update(plane); } } }
public FlightDetailVM(FlightDetailDTO fd, AirportDTO Origin, AirportDTO Destination) { this.FlightId = fd.FlightId; this.FlightDetailId = fd.FlightDetailId; this.RouteId = fd.RouteId; this.OriginAirport = Origin.AirportName; this.OriginCountry = Origin.Address.Country; this.DesAirport = Destination.AirportName; this.DesCountry = Destination.Address.Country; this.ArrDate = fd.ArrDate.ToString(); this.DepDate = fd.DepDate.ToString(); }
public override void AssignFromModel(FlightModel model) { PublicId = model.PublicId; CreatedAt = model.CreatedAt; DepartureAirport = AirportDTO.CreateDTO(model.DepartureAirport); DepartureTime = model.DepartureTime; ArrivalAirport = AirportDTO.CreateDTO(model.ArrivalAirport); ArrivalTime = model.ArrivalTime; DistanceInKm = model.DistanceInKm; Aircraft = AircraftDTO.CreateDTO(model.Aircraft); FuelNeeded = model.FuelNeeded; }
// plane can start departure only if stations 0,1,2,3,7 are empty. public static bool IsClearForDeparturing(AirportDTO airport) { foreach (var plane in airport.Planes) { if (StationsInfoService.IsAttendingToLand(plane.StationId) || StationsInfoService.IsOnTrack(plane.StationId) || StationsInfoService.IsAttendingToDepart(plane.StationId)) { return(false); // the field isnt clear for departuring } } return(true); //the field is clear for departuring }
//removing planes from airport that already departured: private void RemoveDeparturedPlanesFromAirport(AirportDTO airport) { for (int i = 0; i < airport.Planes.Count; i++) { PlaneDTO plane = airport.Planes[i]; //if the plane already left the airport if (StationsInfoService.IsInAir(plane.StationId)) { //remove the plane from the airport: airport.Planes.Remove(plane); } } }
//plane can start arrival/landing only if sations 0,1,2,3,7,4 are empty(4-can start parking) public static bool IsClearForLanding(AirportDTO airport) { // same rules as IsClearForDeparture with the exception of station 4 if (AirportFieldValidator.IsClearForDeparturing(airport)) // if all is true, then can check station 4 { PlaneDTO plane = airport.Planes.FirstOrDefault(p => StationsInfoService.IsAttendingToPark(p.StationId)); if (plane == null) //no { return(true); } } return(false); }
//managing planes mechanisem: public void ManageAirport(AirportDTO airport) { //removing planes from airport that already departured: RemoveDeparturedPlanesFromAirport(airport); //telling the planes in airport where to go //(planes that are already in process of landing/parking/departuring): MangePlanesInAirport(airport); //telling planes on hold if they can land/departure //(telling them to start the process) ManagePlanesOnHold(airport); //updating planes status: PlaneStateUpdater.Update(airport); }
private void MangePlanesInAirport(AirportDTO airport) { //telling planes in airport where to move: for (int i = 0; i < airport.Planes.Count; i++) { PlaneDTO plane = airport.Planes[i]; //if plane landing if (StationsInfoService.IsAttendingToLand(plane.StationId)) { plane.StationId++; } //if plane on track else if (StationsInfoService.IsOnTrack(plane.StationId)) { if (plane.State == PlaneState.Landing) { plane.StationId++; } else//departuring { plane.StationId = StationsInfoService.InAir; //tell the plane departure to air //and from the plansOnHold queue: DeparturePlanesOnHold.Dequeue(); } } //if attending to park else if (StationsInfoService.IsAttendingToPark(plane.StationId)) { //if the parking slots are empty -tell the plane to move there: PlaneDTO firstParkingSlot = airport.Planes.FirstOrDefault(u => u.StationId == StationsInfoService.Parking[0]); PlaneDTO secondParkingSlot = airport.Planes.FirstOrDefault(u => u.StationId == StationsInfoService.Parking[1]); if (firstParkingSlot == null) { plane.StationId = StationsInfoService.Parking[0]; //raise event about the parked plane: PlaneParked.Invoke(plane, EventArgs.Empty); } else if (secondParkingSlot == null) { plane.StationId = StationsInfoService.Parking[1]; //raise event about the parked plane: PlaneParked.Invoke(plane, EventArgs.Empty); } } else if (StationsInfoService.IsAttendingToDepart(plane.StationId)) { plane.StationId = StationsInfoService.Track; } } }
public static Airport Convert(this AirportDTO airportDto) { return(new Airport { ItemId = airportDto.ItemId, IsDeleted = airportDto.IsDeleted, Updated = airportDto.Updated, CorrectorId = airportDto.CorrectorId, ShortName = airportDto.ShortName, FullName = airportDto.FullName, Altitude = airportDto.Altitude ?? default(int), TimeBeginning = airportDto.TimeBeginning ?? default(int), TimeEnd = airportDto.TimeEnd ?? default(int) }); }
/// <summary> /// Date Created: 25/09/2012 /// Created By: Josephine Gad /// (description) Move Airport from right to left /// </summary> private void RemoveAirport() { CheckBox uoCheckBoxSelect; HiddenField uoHiddenFieldAirport; Label uoLabelAirport; List <AirportDTO> listToBeAdded = new List <AirportDTO>(); List <AirportDTO> listAdded = new List <AirportDTO>(); listToBeAdded = GetAirportNotInUser(false, false); listAdded = GetAirportInUser(false); foreach (ListViewItem item in uoListViewAirportSaved.Items) { uoCheckBoxSelect = (CheckBox)item.FindControl("uoCheckBoxSelect"); if (uoCheckBoxSelect.Checked == true) { uoHiddenFieldAirport = (HiddenField)item.FindControl("uoHiddenFieldAirport"); uoLabelAirport = (Label)item.FindControl("uoLabelAirport"); var listToRemove = (from a in listAdded where a.AirportIDString == GlobalCode.Field2String(uoHiddenFieldAirport.Value) select new { VesslID = a.AirportIDString, AirportName = a.AirportNameString, }).ToList(); listAdded.RemoveAll(a => a.AirportIDString == GlobalCode.Field2String(uoHiddenFieldAirport.Value)); AirportDTO removedAirport = new AirportDTO(); removedAirport.AirportIDString = listToRemove[0].VesslID; removedAirport.AirportNameString = listToRemove[0].AirportName; listToBeAdded.Insert(listAdded.Count, removedAirport); } } listToBeAdded = listToBeAdded.OrderBy(a => a.AirportNameString).ToList(); listAdded = listAdded.OrderBy(a => a.AirportNameString).ToList(); Session["AirportListNotInUser"] = listToBeAdded; Session["AirportListInUser"] = listAdded; uoListViewAirport.DataSource = listToBeAdded; uoListViewAirport.DataBind(); uoListViewAirportSaved.DataSource = listAdded; uoListViewAirportSaved.DataBind(); }
public ActionResult Edit(int id) { try { AirportDTO airportDTO = airportService.Get(id); AirportViewModel airportView = new AirportViewModel { Id = airportDTO.Id, Name = airportDTO.Name, Address = airportDTO.Address, Country = airportDTO.Country }; return(View(airportView)); } catch (Exception ex) { ModelState.AddModelError("Error", ex); } return(RedirectToAction("Index")); }
/// <summary> /// Author: Josephine Gad /// Date Created: 04/Jul/2014 /// Description: remove from airport list /// </summary> private void AirportRemove() { List <AirportDTO> listAirportNOTAssigned = new List <AirportDTO>(); List <AirportDTO> listAirportAssigned = new List <AirportDTO>(); listAirportAssigned = GetAirportAssigned(); listAirportNOTAssigned = GetAirportNotAssigned(); AirportDTO item; HiddenField hAirport; CheckBox cSelect; Label lAirport; for (int i = 0; i < uoListViewAirportAssigned.Items.Count; i++) { cSelect = (CheckBox)uoListViewAirportAssigned.Items[i].FindControl("uoCheckBoxSelect"); if (cSelect.Checked) { hAirport = (HiddenField)uoListViewAirportAssigned.Items[i].FindControl("uoHiddenFieldAirport"); lAirport = (Label)uoListViewAirportAssigned.Items[i].FindControl("uoLabelAirport"); item = new AirportDTO(); item.AirportIDString = hAirport.Value; item.AirportNameString = lAirport.Text; listAirportNOTAssigned.Add(item); } } listAirportNOTAssigned = listAirportNOTAssigned.OrderBy(a => a.AirportNameString).ToList(); listAirportAssigned.RemoveAll(a => listAirportNOTAssigned.Exists(b => a.AirportIDString == b.AirportIDString)); listAirportAssigned = listAirportAssigned.OrderBy(a => a.AirportNameString).ToList(); Session["HotelAirportBrandPop_AirportAssigned"] = listAirportAssigned; Session["HotelAirportBrandPop_AirportNotAssigned"] = listAirportNOTAssigned; uoListViewAirportAssigned.DataSource = listAirportAssigned; uoListViewAirportAssigned.DataBind(); uoListViewAirportNotAssigned.DataSource = listAirportNOTAssigned; uoListViewAirportNotAssigned.DataBind(); }
private void ManagePlanesOnHold(AirportDTO airport) { //mangaing the planes that want to departure/arrival: //check if the airport field is clean for departure: if (AirportFieldValidator.IsClearForDeparturing(airport)) { // if there is plane that want to departure: if (DeparturePlanesOnHold.Count != 0) { //tell the plane to departure: PlaneDTO plane = DeparturePlanesOnHold.Peek(); PlaneDTO departuringPlane = airport.Planes.Find(p => p.PlaneId == plane.PlaneId); departuringPlane.StationId = StationsInfoService.AttendToDepart; //raise event that plane is departuring: PlaneDeparturing.Invoke(departuringPlane, EventArgs.Empty); } else //if there isnt planes that want to depart, check if there is plane that want land { // if there is plane that want to land: if (ArrivalPlanesOnHold.Count != 0) { //check if the field clear for landing: if (AirportFieldValidator.IsClearForLanding(airport)) { //if field clear tell the plane to land: PlaneDTO plane = ArrivalPlanesOnHold.Dequeue(); plane.StationId = StationsInfoService.AttendingToLand.First(); //adding plane to airport : airport.Planes.Add(plane); //raise event that plane is arriving: PlaneArriving.Invoke(plane, EventArgs.Empty); } } } } }
public void CreateAirport(AirportDTO request) { var airportEntity = DomainAutoMapper.Map <Data.Entities.Airport>(request); AirportRepository.CreateAirport(airportEntity); }
public void DeleteAirport(AirportDTO airportDTO) { var airportEntity = DomainAutoMapper.Map <Data.Entities.Airport>(airportDTO); AirportRepository.DeleteAirport(airportEntity); }
public void UpdateAirport(AirportDTO request) { var flightEntity = DomainAutoMapper.Map <Data.Entities.Airport>(request); AirportRepository.UpdateAirport(flightEntity); }
public IActionResult GetPage([FromQuery] PaginationOptions options) { return(View("AirportsPage", AirportDTO.CreatePaginatedDTOs(_airportManager.GetPage(options)))); }
public IActionResult GetJSONPage([FromQuery] PaginationOptions options) { return(Json(AirportDTO.CreatePaginatedDTOs(_airportManager.GetPage(options)))); }
public Task <int> CreateAsync([FromBody] AirportDTO airport) => AirportTable.CreateAirport(_dbConnection, airport.Name);
public AirportVM(AirportDTO Airport) { this.AirportId = Airport.AirportId; this.AirportName = Airport.AirportName; this.Address = Airport.Address.toString(); }