private void GetCollectionsDataFromDB() { FlightsViewModel.GetAllCompanies().ForEach(c => Companies.Add(c.name)); FlightsViewModel.GetAllCities().ForEach(c => Cities.Add(c)); FlightsViewModel.GetExistingPlanes().ForEach(p => Planes.Add(p)); FlightsViewModel.GetTrips().ForEach(f => Trips.Add(f)); }
public async Task <IActionResult> PutTrip(long id, Trips trip) { if (id != trip.Id) { return(BadRequest()); } _context.Entry(trip).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TripExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult AddNewRoute(string routeLatList, string routeLngList, string routeDistance) { try { DataContext dc = new DataContext(); Trips newTrip = new Trips(); newTrip.RouteLatList = routeLatList; newTrip.RouteLngList = routeLngList; newTrip.RouteDistance = routeDistance; newTrip.TripDate = DateTime.Now.ToShortDateString(); newTrip.TripStatus = "Open"; using (dc) { dc.trips.Add(newTrip); dc.SaveChanges(); } } catch (Exception ex) { Console.WriteLine("error : " + ex.Message); Debug.WriteLine("error : " + ex.Message); } UpdateCustomerModelStatus(routeLatList, routeLngList); return(Json(new { response = true }, JsonRequestBehavior.AllowGet)); }
private void Customerfrm_Load(object sender, EventArgs e) { simpleButton2.Visible = false; btnUpdate.Visible = false; btnDelete.Visible = false; if (Powers == PowersLog.Administrator || Powers == PowersLog.Saler) { simpleButton2.Visible = true; btnUpdate.Visible = true; btnDelete.Visible = true; } cusList = new CusList(); tripsList = new Trips(); ordersList = new OrderList(); toursList = new ToursList(); lblExpresstion.Text = ""; btnAll.PerformClick(); //Thread.Sleep(2000); //processThread.Abort(); /// //cbbColumns_Load(KhachHang.ColumnNames()); }
private void TextViewData_Click(object sender, EventArgs e) { DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time) { TripDate = time; TextViewData.Text = time.ToString("dd.MM.yyyy"); LoaderView.Visibility = ViewStates.Visible; AnimationLoader.Start(); new Thread(new ThreadStart(delegate //поток для загрузки данных { var cost = Prices.GetPrice(routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id, ObratPO[SpinnerPoEnd.SelectedItemPosition].id, routs[SpinnerRouts.SelectedItemPosition].id); if (cost != "false") { trips = Trips.GetTripsOnDate(TripDate.ToString("yyyy-MM-dd"), routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id.ToString(), ObratPO[SpinnerPoEnd.SelectedItemPosition].id.ToString(), routs[SpinnerRouts.SelectedItemPosition].id.ToString()); ListViewTripsParmetr.Height = Convert.ToInt32(function.convertDpToPixel(90, this)) * trips.Count; RunOnUiThread(() => ListViewTrips.Adapter = new TripsAdapter(this, trips)); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); } else { RunOnUiThread(() => ListViewTrips.Adapter = null); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); RunOnUiThread(() => function.AlertDialogShow("Предупреждение", "Между выбранными пунктами не осуществляется перевозка.", this)); } })).Start(); }); frag.Show(FragmentManager, DatePickerFragment.TAG); }
async Task ExecuteLoadTripsCommand() { if (IsBusy) { return; } try { IsBusy = true; Trips.Clear(); var trips = await DataStore.GetTripsAsync(true); Trips.ReplaceRange(trips); Title = $"Trips ({Trips.Count})"; } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task ExecuteLoadMorePastTripsCommandAsync() { if (IsBusy || !CanLoadMore) { return; } var track = Logger.Instance.TrackTime("LoadMoreTrips"); track?.Start(); ProgressDialogManager.LoadProgressDialog("Loading more trips..."); try { IsBusy = true; CanLoadMore = true; var newCount = Trips.Count + 25; Trips.AddRange(await StoreManager.TripStore.GetItemsAsync(Trips.Count, 25, true)); CanLoadMore = Trips.Count == newCount; } catch (Exception ex) { Logger.Instance.Report(ex); } finally { track?.Stop(); IsBusy = false; ProgressDialogManager.DisposeProgressDialog(); } }
private void LoadTripStartTimes(List <string[]> tripStopTimesData) { Console.WriteLine(this + "Loading Trip Start times..."); List <int> auxTripIdList = new List <int>(); // list to know which trips start time has already been added var watch = Stopwatch.StartNew(); foreach (var tripStopTime in tripStopTimesData) { var tripId = int.Parse(tripStopTime[0]); //the checks below are used to improve the search performance if (!auxTripIdList.Contains(tripId)) //if it doesn't contain in the list { var trip = Trips.Find(t => t.Id == tripId); //finds the trip if (trip != null) //if a trip was found adds the start time to that trip { var tripStartTime = tripStopTime[2]; // start time in hour/minute/second var startTimeInSeconds = TimeSpan.Parse(tripStartTime).TotalSeconds; trip.StartTime = Convert.ToInt32(startTimeInSeconds); auxTripIdList.Add(tripId); //adds to the auxiliary list } } } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; var seconds = elapsedMs * 0.001; Console.WriteLine(this.ToString() + "Trip start times were successfully loaded in " + seconds + " seconds."); }
private void LoadTrips(List <string[]> tripsData) { Console.WriteLine(this + "Loading Trips..."); var watch = Stopwatch.StartNew(); foreach (var tripData in tripsData) { int routeId = int.Parse(tripData[0]); Route route = Routes.Find(r => r.Id == routeId); Trip trip = new Trip(int.Parse(tripData[2]), tripData[3]); trip.Route = route; if (route != null) { if (!route.Trips.Contains(trip)) { Trips.Add(trip); route.Trips.Add(trip); } } } watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; var seconds = elapsedMs * 0.001; Console.WriteLine(this.ToString() + Trips.Count + " trips were successfully loaded in " + seconds + " seconds."); }
protected virtual void ClearNavigationProperties() { PrimaryPrefCustomers.Clear(); SecondaryPrefCustomers.Clear(); Equipments.Clear(); Trips.Clear(); }
public void DeleteTrip(object obj) { Trip trip = obj as Trip; Trips.Remove(trip); _tripRepository.Remove(trip.Id); }
public StudentViewModel(StuProfile student) { Student = student; School = db.Schools.Find(student.SchoolId); User = student.User; Trips = db.Trips .Where(t => t.Student.UserId == student.UserId) .ToList(); if (Trips.Count > 0) { Trip activeTrip = Trips .Where(t => t.IsActive == true && t.StuId == student.Id).FirstOrDefault(); if (activeTrip != null) { ActiveTrip = new TripViewModel(activeTrip); } } Upload = db.Uploads .Where(p => p.TypeRef == "ProfPic" && p.RefId == student.UserId) .FirstOrDefault(); }
public async Task CreateTrip() { //1 - Initialize Trip CurrentTrip = new Trips() { RecordedTimeStamp = DateTime.UtcNow, Name = $"Trip {DateTime.Now}", Id = Guid.NewGuid().ToString(), UserId = "Hacker 1" }; CreateTripPoints(); //TODO : Do proper Distance Calculation and Add a method to determine Rating CurrentTrip.EndTimeStamp = CurrentTrip.TripPoints.Last <TripPoints>().RecordedTimeStamp; CurrentTrip.Rating = 90; //TODO : DO BingMaps Call to determine distance CurrentTrip.Distance = 5.95; //Get Trip POIs and Update Trip Summary Information CreateTripPois(); //Update Driver Profile with Trip Data UpdateUserProfile(); //Add trips to DB Instance await Ctx.Trips.AddAsync(CurrentTrip); }
public Trip GetNewTrip() { var _trip = _tripBridge.GetNewTrip(); Trips.Add(_trip); return(_trip); }
private void SearchInTrips() { SearchExcludedItems.ForEach(t => { if (!Trips.Contains(t)) { Trips.Add(t); } }); SearchResultItems.Clear(); SearchExcludedItems.Clear(); SearchResultItems = Trips.Where(t => t.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) || t.AirwayCompany.ID_comp.ToString().Contains(SearchText) || t.DepTimeString.Contains(SearchText) || t.ArrTimeString.Contains(SearchText) || t.Plane.ToUpper().Contains(SearchText.ToUpper()) || t.TownFrom.ToUpper().Contains(SearchText.ToUpper()) || t.TownTo.ToUpper().Contains(SearchText.ToUpper()) || t.TripNumber.ToString().Contains(SearchText) ).ToList(); SearchExcludedItems = Trips.Where(t => !t.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) || !t.AirwayCompany.ID_comp.ToString().Contains(SearchText) || !t.DepTimeString.Contains(SearchText) || !t.ArrTimeString.Contains(SearchText) || !t.Plane.ToUpper().Contains(SearchText.ToUpper()) || !t.TownFrom.ToUpper().Contains(SearchText.ToUpper()) || !t.TownTo.ToUpper().Contains(SearchText.ToUpper()) || !t.TripNumber.ToString().Contains(SearchText)).ToList(); Trips.Clear(); SearchResultItems.ForEach(t => Trips.Add(t)); }
private void ComboBoxNewMarshrut_SelectedIndexChanged(object sender, EventArgs e) { if (ComboBoxNewMarshrut.SelectedIndex != -1 && ComboBoxOtkyda.SelectedIndex != -1 && ComboBoxKyda.SelectedIndex != -1) { marshruts[ComboBoxNewMarshrut.SelectedIndex].GetPromPynkt(); int j = marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt.Count - 1; // переменная для заполнения ComboBoxKyda ComboBoxOtkyda.Items.Clear(); ComboBoxKyda.Items.Clear(); for (int i = 0; i < marshruts[0].PromPynkt.Count; i++) { ComboBoxOtkyda.Items.Add(marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[i].name); ComboBoxKyda.Items.Add(marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[j].name); j--; } trips = Trips.GetTripsOnDate(DateTimePicker.Value.ToString("yyyy-MM-dd"), marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[ComboBoxOtkyda.SelectedIndex].id.ToString(), marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt.Count - ComboBoxKyda.SelectedIndex - 1].id.ToString(), marshruts[ComboBoxNewMarshrut.SelectedIndex].id.ToString()); ComboBoxCar.Items.Clear(); for (int i = 0; i < trips.Count; i++) { ComboBoxCar.Items.Add("Микроавтобус №" + (i + 1).ToString()); } functions.ClearButtonSvMesta(ButtonMass); LabelSvMest.Text = "Свободных мест: "; // + trips[0].coun_sv_mest; TextBoxCout.Text = ""; // functions.GetPrice(pynkts[0].name, pynkts[pynkts.Count - 1].name); } }
private void SpinnerPoEnd_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { if (SpinnerPoEnd.SelectedItemPosition != -1) { LoaderView.Visibility = ViewStates.Visible; AnimationLoader.Start(); new Thread(new ThreadStart(delegate //поток для загрузки данных { var cost = Prices.GetPrice(routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id, ObratPO[SpinnerPoEnd.SelectedItemPosition].id, routs[SpinnerRouts.SelectedItemPosition].id); if (cost != "false") { trips = Trips.GetTripsOnDate(TripDate.ToString("yyyy-MM-dd"), routs[SpinnerRouts.SelectedItemPosition].PromPynkt[SpinnerPoStart.SelectedItemPosition].id.ToString(), ObratPO[SpinnerPoEnd.SelectedItemPosition].id.ToString(), routs[SpinnerRouts.SelectedItemPosition].id.ToString()); ListViewTripsParmetr.Height = Convert.ToInt32(function.convertDpToPixel(90, this)) * trips.Count; RunOnUiThread(() => ListViewTrips.Adapter = new TripsAdapter(this, trips)); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); } else { RunOnUiThread(() => ListViewTrips.Adapter = null); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); RunOnUiThread(() => function.AlertDialogShow("Предупреждение", "Между выбранными пунктами не осуществляется перевозка.", this)); } })).Start(); } }
public TripsContext(DbContextOptions <TripsContext> options) : base(options) { if (Trips.Any()) { return; } Trips.AddRange(new List <Trip> { new Trip { Name = "San Franis college", StartDate = new DateTime(2019, 5, 4), EndDate = new DateTime(2019, 5, 7) }, new Trip { Name = "Bithoor Live Meet", StartDate = new DateTime(2019, 5, 14), EndDate = new DateTime(2019, 5, 17) }, new Trip { Name = "Local Meetup", StartDate = new DateTime(2019, 5, 24), EndDate = new DateTime(2019, 5, 27) } }); SaveChanges(); }
public async Task <ActionResult <Trips> > PostTrip(Trips trip) { _context.Trip.Add(trip); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTrip", new { id = trip.Id }, trip)); }
public ActionResult DeleteConfirmed(int id) { Trips trip = db.trips.Find(id); db.trips.Remove(trip); db.SaveChanges(); return(RedirectToAction("MyTrips")); }
private void ComboBoxCar_SelectedIndexChanged(object sender, EventArgs e) { functions.ClearButtonSvMesta(ButtonMass); ComboBoxMesto.Items.Clear(); mesta = Trips.GetMesta(trips[ComboBoxCar.SelectedIndex].id, marshruts[ComboBoxNewMarshrut.SelectedIndex].id, marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[ComboBoxOtkyda.SelectedIndex].id, marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt[marshruts[ComboBoxNewMarshrut.SelectedIndex].PromPynkt.Count - 1 - ComboBoxKyda.SelectedIndex].id); functions.CheckSvMestaOnShema(mesta, ButtonMass, ComboBoxMesto); LabelSvMest.Text = "Свободных мест: " + trips[ComboBoxCar.SelectedIndex].coun_sv_mest; }
public ActionResult DeleteConfirmed(string id) { Trips trips = db.Trips.Find(id); db.Trips.Remove(trips); db.SaveChanges(); return(RedirectToAction("Index")); }
public void ShouldGetTripByIdReturnRightTrip() { var sampleTrip = Trips.First(); var trip = TripManager.GetTripById(sampleTrip.Key); Assert.That(trip, Is.EqualTo(sampleTrip.Value)); var unused = Uow.DidNotReceive().CommitAsync(); }
public void Recycle() { Release(); foreach (var t in Trips) { t.Recycle(); } Trips.Clear(); }
public IActionResult New(Trips trip) { string name = trip.Name; bool isGood = trip.IsGood; double miles = trip.Miles; trips.Add(new Trips(name, isGood, miles)); return(RedirectToAction("Index")); }
public Places(string name, string picture, string stayLength, string timeTravel) { Name = name; Picture = picture; StayLength = stayLength; TravelTime = timeTravel; Id = Trips.Count + 1; Trips.Add(this); }
public FavouriteTripDisplay(NavigationPage page, DefaultMap map, int tripId) { Map = map; NavPage = page; var isFavorite = MapUtil.Favorites.Contains(tripId); var isDelayed = MapUtil.IsTripDelayed(tripId); Trip = Trips.GetTripWithTripId(tripId); _favouriteButton = new Button { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Image = isFavorite ? StarDisabled : StarAccept, IsEnabled = !isFavorite, Margin = new Thickness(0, 40, 0, 0) }; _issueLabel = new Label { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, Text = isDelayed ? "Delayed by " + (MapUtil.DelayTable[tripId] / 60) + " minute(s)." : "On Schedule", Margin = new Thickness(0, 20, 0, 0), TextColor = isDelayed ? Red : Blue }; _gotoButton = new Button { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, Text = "Go to Bus..." }; _favouriteButton.Clicked += OnFavourite; _gotoButton.Clicked += OnGoto; //TODO just realised this is kinda redundant Content=Content= Content = new ContentPage { Content = new StackLayout { Children = { new Label { Margin = new Thickness(0, 40, 0, 0), HorizontalOptions = LayoutOptions.Center, Text = Trip.Route.Name }, new Label { HorizontalOptions = LayoutOptions.Center, Text = Trip.Id + " (" + Trip.ListStopTimeRangeAsString() + ")" }, _favouriteButton, _issueLabel, _gotoButton } } }; }
private void DeleteTrip() { if (SelectedTrip != null) { List <TripModel> flights = new List <TripModel>(FlightsViewModel.GetFlightsByTripNumber(SelectedTrip.TripNumber)); List <TripModel> returnFlights = new List <TripModel>(); if (SelectedTrip.ReturnTripBool) { returnFlights = FlightsViewModel.GetFlightsByTripNumber(SelectedTrip.ReturnTripN); } if (flights.Count > 0) { StringBuilder st = new StringBuilder(); flights.ForEach(f => { st.Append(" " + f.Date); }); string message; if (flights.Count == 1) { message = "This trip can not be deleted because there is " + flights.Count + " flight in the schedule based on this trip with dates:" + st.ToString() + "." + " You should remove all flights based on this trip."; } else { message = "This trip can not be deleted because there are " + flights.Count + " flights in the schedule based on this trip with dates:" + st.ToString() + "." + " You should remove all flights based on this trip."; } MessageBox.Show(message, "Delete trip", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { string message = "Delete trip " + SelectedTrip.TripNumber + " " + SelectedTrip.TownFrom + " - " + SelectedTrip.TownTo + " by " + SelectedTrip.AirwayCompany + " " + SelectedTrip.DepTime.ToShortTimeString() + " - " + SelectedTrip.ArrTime.ToShortTimeString() + " on " + SelectedTrip.Plane + "?"; DialogResult result = System.Windows.Forms.MessageBox.Show(message, "Delete trip", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (SelectedTrip.ReturnTripBool) { string message1 = "Trip " + SelectedTrip.TripNumber + " " + SelectedTrip.TownFrom + " - " + SelectedTrip.TownTo + " has return trip number " + SelectedTrip.ReturnTripN + ". Delete return trip as well?"; DialogResult result1 = MessageBox.Show(message1, "Delete return trip", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { if (returnFlights.Count > 0) { StringBuilder st = new StringBuilder(); returnFlights.ForEach(f => { st.Append(" " + f.Date); }); string message2 = "This trip can not be deleted because there are " + returnFlights.Count + " flights in the schedule based on this trip with dates:" + st.ToString() + "." + " You should remove all flights based on this trip."; MessageBox.Show(message2, "Delete return trip", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { FlightsViewModel.DeleteTrip(SelectedTrip.ReturnTrip); Trips.Remove(SelectedTrip.ReturnTrip); } } } if (result == DialogResult.Yes) { FlightsViewModel.DeleteTrip(SelectedTrip); Trips.Remove(SelectedTrip); } } } }
/// <summary> /// Gets all tables of this database /// </summary> private static void GetTables() { ClientsInstance = new Clients(Connection); EmployeesInstance = new Employees(Connection); OrdersInstance = new Orders(Connection); ReservationsInstance = new Reservations(Connection); TripsInstance = new Trips(Connection); InvoicesInstance = new Invoices(Connection); PaymentsInstance = new Payments(Connection); }
public ActionResult Edit([Bind(Include = "trip_id,route_id,service_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,wheelchair_accessible,bikes_allowed")] Trips trips) { if (ModelState.IsValid) { db.Entry(trips).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(trips)); }