public ActionResult Edit([Bind(Include = "FlightID,DeparturePlace,DestinationPlace,DepartureTime,ArrivalTime,FlightStatus,PlaneID,StripID")] flight flight) { if (ModelState.IsValid) { db.Entry(flight).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlaneID = new SelectList(db.plane, "PlaneID", "Type", flight.PlaneID); return(View(flight)); }
public ActionResult Edit([Bind(Include = "ID_flight,driver,ID_bus,ID_route")] flight flight) { if (ModelState.IsValid) { db.Entry(flight).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_bus = new SelectList(db.bus, "ID_bus", "regist_number", flight.ID_bus); ViewBag.ID_route = new SelectList(db.route, "ID_route", "destination", flight.ID_route); return(View(flight)); }
public IHttpActionResult Postflight(flight flight) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.flights.Add(flight); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = flight.flights_Id }, flight)); }
// GET: flights/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } flight flight = db.flight.Find(id); if (flight == null) { return(HttpNotFound()); } return(View(flight)); }
public IHttpActionResult Deleteflight(int id) { flight flight = db.flights.Find(id); if (flight == null) { return(NotFound()); } db.flights.Remove(flight); db.SaveChanges(); return(Ok(flight)); }
// GET: flights/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } flight flight = db.flight.Find(id); if (flight == null) { return(HttpNotFound()); } ViewBag.ID_bus = new SelectList(db.bus, "ID_bus", "regist_number", flight.ID_bus); ViewBag.ID_route = new SelectList(db.route, "ID_route", "destination", flight.ID_route); return(View(flight)); }
//Returning a collection of passengers with tickets for flight public ActionResult Passengers(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } flight flight = db.flight.Find(id); if (flight == null) { return(HttpNotFound()); } IEnumerable <passengers> passengers = flight.ticket.Select(a => a.passengers); return(View(passengers)); }
public JsonResult Edit(int id) { Dictionary <string, object> result = new Dictionary <string, object>(); try { flight flight = _dbContext.flights.Find(id); serializeToModel(ref flight); _dbContext.SaveChanges(); } catch (Exception exc) { result.Add("error", exc.Message); } return(Json(result, JsonRequestBehavior.DenyGet)); }
public HttpResponseMessage Post([FromBody] flight flightObj) { try { using (FlightsBookingInfoDatabaseEntities entities = new FlightsBookingInfoDatabaseEntities()) { entities.flights.Add(flightObj); entities.SaveChanges(); var message = Request.CreateResponse(HttpStatusCode.Created, flightObj); message.Headers.Location = new Uri(Request.RequestUri + flightObj.id.ToString()); return(message); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public List <flight> sortData(List <string> FlightList) { string[] dataArray; flightData = new List <flight>(); List <flight> sortedFlightList; var uniqueFlight = (from uniqueFlightList in FlightList select uniqueFlightList).Distinct().ToList(); foreach (var line in uniqueFlight) { if ((line != "Origin,Departure Time,Destination,Destination Time,Price") && (line != "Origin|Departure Time|Destination|Destination Time|Price")) { if (line.Contains(",")) { dataArray = line.Split(','); flight flt = new flight() { Origin = dataArray[0].ToLower(), DepartureTime = dataArray[1], Destination = dataArray[2].ToLower(), DestinationTime = dataArray[3], price = dataArray[4] }; flightData.Add(flt); } else { dataArray = line.Split('|'); flight flt = new flight() { Origin = dataArray[0], DepartureTime = dataArray[1], Destination = dataArray[2], DestinationTime = dataArray[3], price = dataArray[4] }; flightData.Add(flt); } } } sortedFlightList = flightData.OrderBy(x => x.price).ToList(); return(sortedFlightList); }
public ActionResult DisplayListObject(int id) { //debut code khawla IUserService service = new UserService(); user u = service.GetById(User.Identity.GetUserId()); string firstName = u.firstName; string lastName = u.lastName; string email = u.Email; ViewBag.userFirstName = firstName; ViewBag.userLastName = lastName; ViewBag.userMail = email; ViewBag.sexe = u.sexe.ToLower(); //fin code khawla var l = ause.GetById(id); flight f = ause.GetById(id); return(View(ause.GetById(1))); }
private void serializeToModel(ref flight flight) { if (Request.Form["airline_id"] == "") { flight.airline_id = null; } else { flight.airline_id = int.Parse(Request.Form["airline_id"]); } flight.code = Request.Form["code"]; flight.from_airport_id = int.Parse(Request.Form["from_airport_id"]); flight.to_airport_id = int.Parse(Request.Form["to_airport_id"]); flight.flight_at = Utils.dtToTimestamp(Convert.ToDateTime(Request.Form["flight_at"])); flight.duration = int.Parse(Request.Form["duration"]); flight.cost = int.Parse(Request.Form["cost"]); flight.total_seats = int.Parse(Request.Form["total_seats"]); }
//// GET: flights/Create //public ActionResult Create() //{ // ViewBag.PlaneID = new SelectList(db.plane, "PlaneID", "Type"); // return View(); //} //// POST: flights/Create //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Create([Bind(Include = "FlightID,DeparturePlace,DestinationPlace,DepartureTime,ArrivalTime,FlightStatus,PlaneID,StripID")] flight flight) //{ // if (ModelState.IsValid) // { // db.flight.Add(flight); // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.PlaneID = new SelectList(db.plane, "PlaneID", "Type", flight.PlaneID); // return View(flight); //} // GET: flights/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } flight flight = db.flight.Find(id); if (flight == null) { return(HttpNotFound()); } ViewBag.PlaneID = new SelectList(db.plane, "PlaneID", "Type", flight.PlaneID); IEnumerable <passengers> passengers = flight.ticket.Select(a => a.passengers); ViewBag.PassengersList = passengers; return(View(flight)); }
public static void WriteFile(AirCompany company) { StreamWriter Out; try { Out = new StreamWriter(Constants.path); Out.Write(""); for (int i = 0; i < company.GetCountOfFlights(); i++) { flight f = company.GetFlight(i); Out.WriteLine(JsonConvert.SerializeObject(f)); } Out.Close(); } catch { return; } }
private void btnBuy_Click(object sender, EventArgs e) { if (gridFlights.SelectedRows.Count > 0) { buyForm buyForm = new buyForm(); long flightId = Convert.ToInt64(gridFlights.SelectedRows[0].Cells[0].Value); flight flightItem = getFlight(flightId); buyForm.flight = flightItem; buyForm.client = client; buyForm.ShowDialog(); updateFlights(); } }
private void serializeToAirticketModel(ref airticket airticket) { flight flight = null; if (Request.Form["flight_id"] != "") { airticket.flight_id = int.Parse(Request.Form["flight_id"]); flight = _dbContext.flights.Find(airticket.flight_id); } else { airticket.flight_id = null; } airticket.departure_at = Utils.dtToTimestamp(Convert.ToDateTime(Request.Form["departure_at"])); airticket.created_at = Utils.dtToTimestamp(DateTime.Now); airticket.callout_id = int.Parse(Request.Form["callout_id"]); airticket.is_baby = Request.Form["is_baby"] == "on" ? 1 : 0; airticket.is_baggage = Request.Form["is_baggage"] == "on" ? 1 : 0; airticket.payment = 0; if (flight != null) { airticket.payment = flight.cost; } if (airticket.is_baggage == 1) { airticket.payment += airticket.payment / 10; } if (airticket.is_baby == 1) { airticket.payment = 0; } }
// GET: Payment public JsonResult Index1(flight f) { if (Session["username"] == null) { return(Json(new { status = false })); } else { Session["flight_id"] = f.flight_id; Hashtable orderdetails = new Hashtable(); orderdetails.Add("flight_id", f.flight_id); orderdetails.Add("airline_name", f.airline_id); orderdetails.Add("flight_no", f.flight_no); orderdetails.Add("flight_from", f.flight_timing_from); orderdetails.Add("flight_to", f.flight_timing_to); orderdetails.Add("operating_date_from", f.operating_date_from); orderdetails.Add("operating_date_to", f.operating_date_to); orderdetails.Add("flight_timing_from", f.flight_timing_from); orderdetails.Add("flight_timing_to", f.flight_timing_to); orderdetails.Add("class_type", "economy"); // or first orderdetails.Add("cost", f.cost); //System.Diagnostics.Debug.WriteLine("qty is "); //System.Diagnostics.Debug.WriteLine(Session["qty"]); orderdetails.Add("qty", (int)Session["qty"]); // orderdetails.Add("Totalcost", f.cost * ((int)Session["qty"])); orderdetails.Add("Totalcost", f.cost * (int)Session["qty"]); List <Hashtable> orders = new List <Hashtable>(); orders.Add(orderdetails); //orders.Add(orderdetails1); TempData["flight_details"] = orders; return(Json(new { status = true })); } //return View("Index"); }
public override async Task <bool> Reserve(reserve reserve) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); string webServiceAvianca = configuration.GetValue <string>("WebServiceAvianca"); webServiceAvianca += "reserveFlight"; flight flight = new flight { order_id = reserve.order_id, first_name = reserve.first_name, last_name = reserve.last_name, departure_date = reserve.departure_date, departure_hour = reserve.departure_hour, trip_number = reserve.trip_number, chair_number = reserve.chair_number, origin = reserve.origin, destiny = reserve.destiny }; string body = JsonConvert.SerializeObject(flight); StringContent stringContent = new StringContent(body, Encoding.UTF8, "application/json"); HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(webServiceAvianca, stringContent); if (httpResponseMessage.IsSuccessStatusCode) { return(true); } else { throw new Exception(await httpResponseMessage.Content.ReadAsStringAsync()); } }
public JsonResult Delete(int id) { Dictionary <string, object> result = new Dictionary <string, object>(); try { flight flight = _dbContext.flights.Find(id); if (flight != null) { _dbContext.flights.Remove(flight); _dbContext.SaveChanges(); } else { result.Add("error", "Авиарейс не найден"); } } catch (Exception exc) { result.Add("error", exc.Message); } return(Json(result, JsonRequestBehavior.DenyGet)); }
public ActionResult Create(flight f) { //debut code khawla IUserService service = new UserService(); user u = service.GetById(User.Identity.GetUserId()); string firstName = u.firstName; string lastName = u.lastName; string email = u.Email; ViewBag.userFirstName = firstName; ViewBag.userLastName = lastName; ViewBag.userMail = email; ViewBag.sexe = u.sexe.ToLower(); //fin code khawla if (ModelState.IsValid) { ause.Add(f); return(RedirectToAction("Index")); } else { return(View()); } }
private void Proxy_GetFlightsCompleted(object sender, ServiceReference2.GetFlightsCompletedEventArgs e) { XElement root = e.Result; //a = new ObservableCollection<Test>(); bool belgiArrival = false; foreach (XElement rootElm in root.Elements()) { if (rootElm.Name.LocalName.Contains("Data")) { foreach (XElement dataElm in rootElm.Elements()) { if (dataElm.Name.LocalName.Contains("Flights")) { // What do you want to add? The Attribute? Element value foreach (XElement flightSSElm in dataElm.Elements()) { if (flightSSElm.Name.LocalName.Contains("Flight")) { flight selFlight = new flight(); foreach (XElement flightElm in flightSSElm.Elements()) { if (flightElm.Name.LocalName.Contains("FlightId")) { foreach (XElement flightIDelm in flightElm.Elements()) { if (flightIDelm.Name.LocalName.Contains("FlightKind")) { if (flightIDelm.Value == "Arrival") { belgiArrival = true; } } else if (flightIDelm.Name.LocalName.Contains("FlightNumber") && belgiArrival) { selFlight.FlightNumber = flightIDelm.Value.ToString(); } else if (flightIDelm.Name.LocalName.Contains("AirlineDesignator") && flightIDelm.Attribute("codeContext").Value.Contains("IATA") && belgiArrival) { selFlight.CIata = flightIDelm.Value.ToString(); } } } else if (flightElm.Name.LocalName.Contains("FlightState") && belgiArrival) { foreach (XElement flighStateelement in flightElm.Elements()) { if (flighStateelement.Name.LocalName.Contains("ScheduledTime")) { //selFlight.FlightSTA = DateTime.Parse(flighStateelement.Value); selFlight.FlightSTA = Convert.ToDateTime(flighStateelement.Value); // selFlight.Email = flighStateelement.Value.ToString(); } else if (flighStateelement.Name.LocalName.Contains("Value") && flighStateelement.Attribute("propertyName").Value.Contains("ON CHOCKS")) { //selFlight.FlightSTA = DateTime.Parse(flighStateelement.Value); selFlight.FlightOnBlockTA = Convert.ToDateTime(flighStateelement.Value); // selFlight.Email = flighStateelement.Value.ToString(); } } belgiArrival = false; oflight.Add(selFlight); } } } } } } } } //employees.Add(new Employee { DisplayName = "GetFlights" }); }
public JsonResult Suggestions(int id) { double totalPayment = 0; // С вкладки Заявки Админки при клике на заявку сюда приходит id выбранной заявки callout callout = _dbContext.callouts.Where(c => c.id == id).FirstOrDefault(); // Сбор данных о авиабилетах List <object> airticketsList = new List <object>(); foreach (airticket airticket in callout.airtickets) { flight flight = airticket.flight; double payment = 0; if (flight != null) { payment = flight.cost; } if (airticket.is_baggage == 1) { payment += payment * 0.1; } if (airticket.is_baby == 1) { payment = 0; } totalPayment += payment; airticketsList.Add(new { id = airticket.id, created_datetime = Utils.tsToDateTime(airticket.created_at).ToString(Constants.ddMMMyyyyHmmss), departure_at = airticket.departure_at, flight = flight != null ? new { id = flight.id, airline_name = flight.airline.name, code = flight.code, duration = flight.duration, cost = flight.cost, total_seats = flight.total_seats } : null, payment = airticket.payment == 0 ? payment : airticket.payment, is_baggage = airticket.is_baggage, is_baby = airticket.is_baby }); } // Сбор данных о трансферах List <object> transfersList = new List <object>(); foreach (transfer transfer in callout.transfers) { route route = transfer.route; airport fromAirport = null; airport toAirport = null; double payment = 0; if (route != null) { fromAirport = route.airport; toAirport = route.airport1; payment = route.cost; } if (transfer.is_baggage == 1) { payment += payment * 0.1; } if (transfer.is_baby == 1) { payment = 0; } totalPayment += payment; transfersList.Add(new { id = transfer.id, starting_date = transfer.starting_date.ToString(Constants.ddMMMyyyy), created_datetime = Utils.tsToDateTime(transfer.created_at).ToString(Constants.ddMMMyyyyHmmss), is_baggage = transfer.is_baggage, is_baby = transfer.is_baby, payment = transfer.payment == 0 ? payment : transfer.payment, route = route != null ? new { id = route.id, type = route.type, from_airport = fromAirport != null ? new { id = fromAirport.id, name = fromAirport.name, city_name = fromAirport.city.name } : null, to_airport = toAirport != null ? new { id = toAirport.id, name = toAirport.name, city_name = toAirport.city.name } : null, starting_address = route.starting_address, starting_time = route.starting_time.ToString(Constants.hhmmss), final_address = route.final_address, duration = route.duration, total_seats = route.total_seats, distance = route.distance, cost = route.cost, } : null }); } // Сбор данных о желаемых комнатах List <object> calloutRoomsList = new List <object>(); foreach (callout_room calloutRoom in callout.callout_room) { room room = calloutRoom.room; hotel hotel = room.hotel; food food = hotel.food; city city = hotel.city; country country = city.country; int numberNights = calloutRoom.duration / 24; double payment = calloutRoom.room.cost_per_day * numberNights; totalPayment += payment; calloutRoomsList.Add(new { id = calloutRoom.id, created_datetime = Utils.tsToDateTime(calloutRoom.created_at).ToString(Constants.ddMMMyyyyHmmss), start_living_datetime = Utils.tsToDateTime(calloutRoom.start_living_at).ToString(Constants.ddMMMyyyyHmmss), start_living_at = calloutRoom.start_living_at, duration = calloutRoom.duration, payment = calloutRoom.payment == 0 ? payment : calloutRoom.payment, room = new { id = room.id, number = room.number, @class = room.type, seats_number = room.seats_number, room_size = room.room_size, description = room.description, hotel = new { id = hotel.id, name = hotel.name, stars_number = hotel.stars_number, distance_to_beach = hotel.distance_to_beach, food = food != null ? new { id = food.id, type = food.type, description = food.description } : null, city = new { id = city.id, name = city.name, country = new { id = country.id, name = country.name } } } } }); } // Сбор данных об экскурсиях в заявке List <object> excursionOrdersList = new List <object>(); foreach (excursion_order excursionOrder in callout.excursion_order) { excursion excursion = excursionOrder.excursion; double payment = excursion.cost; if (excursionOrder.is_privilege == 1) { payment -= payment * 0.5; } if (excursionOrder.is_baby == 1) { payment = 0; } totalPayment += payment; excursionOrdersList.Add(new { id = excursionOrder.id, created_datetime = Utils.tsToDateTime(excursionOrder.created_at).ToString(Constants.ddMMMyyyyHmmss), starting_address = excursionOrder.starting_address, starting_datetime = Utils.tsToDateTime(excursionOrder.starting_at).ToString(Constants.ddMMMyyyy), starting_at = excursionOrder.starting_at, is_baby = excursionOrder.is_baby, is_privilege = excursionOrder.is_privilege, is_custom = excursionOrder.is_custom, bus_place_number = excursionOrder.bus_place_number, payment = excursionOrder.payment == 0 ? payment : excursionOrder.payment, excursion = new { id = excursion.id, name = excursion.name, starting_time = excursion.starting_time != null ? ((TimeSpan)excursion.starting_time).ToString(Constants.hhmmss) : null, duration = excursion.duration, city_name = excursion.city != null ? excursion.city.name : null, description = excursion.description } }); } // Сбор данных о платных услугах в заявке List <object> hotelServiceOrdersList = new List <object>(); foreach (hotel_service_order hotelServiceOrder in callout.hotel_service_order) { hotel_service service = hotelServiceOrder.hotel_service; double payment = service.cost_per_min * hotelServiceOrder.duration; totalPayment += payment; hotelServiceOrdersList.Add(new { id = hotelServiceOrder.id, created_datetime = Utils.tsToDateTime(hotelServiceOrder.created_at).ToString(Constants.ddMMMyyyyHmmss), provision_datetime = Utils.tsToDateTime(hotelServiceOrder.provision_at).ToString(Constants.ddMMMyyyyHmmss), provision_at = hotelServiceOrder.provision_at, duration = hotelServiceOrder.duration, payment = hotelServiceOrder.payment == 0 ? payment : hotelServiceOrder.payment, room = hotelServiceOrder.room != null ? new { id = hotelServiceOrder.room.id, number = hotelServiceOrder.room.number } : null, hotel_service = new { id = service.id, hotel_name = service.hotel.name, description = service.description, starting_time = service.starting_time != null ? ((TimeSpan)service.starting_time).ToString(Constants.hhmmss) : null } }); } // возврат данных на фронтэнд (клиенту) return(Json(new { airtickets = airticketsList, transfers = transfersList, callout_rooms = calloutRoomsList, excursion_orders = excursionOrdersList, hotel_service_orders = hotelServiceOrdersList, total_payment = totalPayment, is_services = airticketsList.Count() > 0 || transfersList.Count() > 0 || calloutRoomsList.Count() > 0 || excursionOrdersList.Count() > 0 || hotelServiceOrdersList.Count() > 0 }, JsonRequestBehavior.DenyGet)); }
void Start() { birds = player.GetComponent <flight>(); }