public async Task <TripInformation> AddTrip(TripModel model) { //Gelen istek içerisinde Nerden , Nereye , Tarih , Açıklama ve Koltuk sayısının yanında oluşturan kişinin ID sini alıp DB ye kayıt edilen fonksiyon. var tripEntity = new TripInformation { Explanation = model.Explanation, From = model.From, To = model.To, Date = model.Date, SeatCount = model.SeatCount, CreatedBy = model.CreatedBy }; try { await _unitOfWork.TripInformation.Add(tripEntity); _unitOfWork.Complete(); return(tripEntity); } catch (Exception e) { return(null); } }
public void Process(TripModel trip) { // Update trip metadata trip.InvalidDriver = false; trip.DriverTag = 1; trip.Driver = "Test"; }
protected override void OnElementChanged(ElementChangedEventArgs <Map> e) { base.OnElementChanged(e); if (e.OldElement != null) { nativeMap.MapElementClick -= OnMapElementClick; nativeMap.Children.Clear(); markerWindow = null; nativeMap = null; } if (e.NewElement != null) { this.user = (e.NewElement as CustomMap).User; this.trip = (e.NewElement as CustomMap).Trip; var formsMap = (CustomMap)e.NewElement; nativeMap = Control as MapControl; nativeMap.Children.Clear(); nativeMap.MapElementClick += OnMapElementClick; Generatepoint(trip.OriginCoordinates, "origin.png"); Generatepoint(user.CurrentLocation.Latitude + " " + user.CurrentLocation.Longitude, "current.png"); Generatepoint(trip.DestinationCoordinates, "destination.png"); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (trajetList.SelectedValue != null && datedebut.SelectedDate != null && datefin.SelectedDate != null && PresetTimePickerDebut.SelectedTime != null && PresetTimePickerFin.SelectedTime != null) { if (datedebut.SelectedDate > minD && datefin.SelectedDate < maxF) { FlyModel.AddFly(new Fly() { hour_start = datedebut.SelectedDate.Value.AddHours(PresetTimePickerDebut.SelectedTime.Value.Hour).AddMinutes(PresetTimePickerDebut.SelectedTime.Value.Minute), hour_end = datefin.SelectedDate.Value.AddHours(PresetTimePickerFin.SelectedTime.Value.Hour).AddMinutes(PresetTimePickerFin.SelectedTime.Value.Minute), trip_used = TripModel.GetTrip(Convert.ToInt32(trajetList.SelectedValue)), plane = PlaneModel.GetPlane(idAvion) }); Close(); } else { MessageBox.Show("Veuillez choisir les dates de départ et d'arrivé entre le " + minD + " et le " + maxF + ""); } } else { Error.Visibility = Visibility.Visible; } }
public TripMapPage(TripModel tripSelected) { InitializeComponent(); MapTrip.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(tripSelected.Latitude, tripSelected.Longitude), Distance.FromMiles(.5) )); tripSelected.ImageUrl = new ImageService().SaveImageFromBase64(tripSelected.ImageUrl); MapTrip.Trip = tripSelected; MapTrip.Pins.Add( new Pin { Type = PinType.Place, Label = tripSelected.Title, Position = new Position(tripSelected.Latitude, tripSelected.Longitude) } ); Title.Text = tripSelected.Title; Date.Text = tripSelected.TripDate.ToShortDateString(); Rating.Text = $"{tripSelected.Rating} Estrellas"; Notes.Text = tripSelected.Notes; }
public MarkerWindow(TripModel trip) { this.InitializeComponent(); MarkerWindowImage.Source = new BitmapImage(new Uri(trip.ImageUrl)); MarkerWindowTitle.Text = trip.Title; MarkerWindowNotes.Text = trip.Notes; }
private IEnumerable <TripModel> MapTrips(IEnumerable <LocationEntity> locations, int medianTimeSpanBetweenLocations) { List <TripModel> trips = new List <TripModel>(); TripModel lastTrip = null; LocationEntity lastLocation = null; foreach (LocationEntity location in locations) { TimeSpan?timeSpan = GetTimeSpan(lastTrip, location); if ((lastTrip == null || timeSpan == null || timeSpan.Value.TotalSeconds > medianTimeSpanBetweenLocations) && DifferentConnectionId(lastLocation, location)) { lastTrip = new TripModel(); trips.Add(lastTrip); } lastTrip?.Locations.Add(mapper.Map <LocationEntity, LocationModel>(location)); lastLocation = location; } trips = trips.Where(x => x.Distance > 100).ToList(); int tripNo = 1; trips.ForEach(x => x.Number = tripNo++); return(trips); }
public async Task <ActionResult <TripModel> > PostTripModel(TripModel trip) { _context.Trips.Add(trip); await _context.SaveChangesAsync(); return(trip); }
public virtual IActionResult Create(TripModel model, bool continueEditing) { if (!permissionService.Authorize(StandardPermissionProvider.ManageTrips)) { return(AccessDeniedView()); } if (ModelState.IsValid) { var entity = model.ToEntity <Trip>(); tripService.Insert(entity); // activity log customerActivityService.InsertActivity("AddNewTrip", string.Format(localizationService.GetResource("ActivityLog.AddNewTrip"), entity.Id), entity); SuccessNotification(localizationService.GetResource("Admin.Logistics.Trip.Added")); if (!continueEditing) { return(RedirectToAction("List")); } SaveSelectedTabName(); return(RedirectToAction("Edit", new { id = entity.Id })); } model = tripFactory.PrepareModel(model, null, true); return(View(model)); }
public ActionResult Customer(int id) { List <TripModel> lstTrip = new List <TripModel>(); objModel = objService.getByID(id); return(View(objModel)); }
public static TripModel ChangeFlightData(TripModel oldFlightData) { if (ChangedFlight != null) { foreach (var p in oldFlightData.PassengersList) { Pass_in_trip pass_In_Trip = new Pass_in_trip { trip_no = oldFlightData.TripNumber, place = p.SeatNumber, date = DateTime.Parse(oldFlightData.Date), ID_psg = p.Id }; DAL.EditDB.DeletePassengerFromFlight(pass_In_Trip); } foreach (var p in ChangedFlight.PassengersList) { Pass_in_trip pass_In_Trip = new Pass_in_trip { trip_no = ChangedFlight.TripNumber, place = p.SeatNumber, date = DateTime.Parse(ChangedFlight.Date), ID_psg = p.Id }; DAL.EditDB.AddNewPassengerToFlight(ChangedFlight.TripNumber, DateTime.Parse(ChangedFlight.Date), p.Id, p.SeatNumber); } return(ChangedFlight); } else { return(null); } }
public async Task <IActionResult> PutTrip([FromRoute] int id, [FromBody] TripModel tripModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tripModel.tripId) { return(BadRequest()); } if (!TripExists(id)) { return(NotFound()); } try { var dao = new TripDao(_db); tripModel = await dao.saveTripAsync(tripModel); } catch (Exception e) { if (!TripExists(id)) { return(NotFound()); } return(BadRequest(new { message = ErrorUtils.dbErrorMessage($"Can't save Trip with id={id}", e) })); } return(NoContent()); // Or Ok(tripModel); }
public List <TripModel> sortByRating(List <TripModel> trips, List <float> tripRevAvgs) { List <TripModel> sortedTop3 = new List <TripModel>(); int i = 0; while (i < 2) { if (tripRevAvgs[i] < tripRevAvgs[i + 1]) { TripModel temp = trips[i]; trips[i] = trips[i + 1]; trips[i + 1] = temp; float tempRevAvg = tripRevAvgs[i]; tripRevAvgs[i] = tripRevAvgs[i + 1]; tripRevAvgs[i + 1] = tempRevAvg; i = -1; } i++; } foreach (TripModel trip in trips) { sortedTop3.Add(trip); } return(sortedTop3); }
// When you buy a trip public ActionResult confirmTrip(Boolean flag, int id) { //flag = false; // laikinas if (flag) { checkGroupList(); } TripModel trip = null; List <TripModel> tripsList = getTripList(); foreach (TripModel ListTrip in tripsList) { if (ListTrip.id == id) { trip = ListTrip; break; } } OrderController.sendPaymentInfo(trip); return(OpenPaymentWindow(trip)); }
public MapPage(UserModel userSelected, TripModel tripSelected) { InitializeComponent(); //Application.Current.MainPage.DisplayAlert("¡AAAAAAAA!", "AAAAAAAAAAAAAAAAAAAA", "Ok"); trip = tripSelected; MapPet.MoveToRegion( MapSpan.FromCenterAndRadius( new Position(Double.Parse(userSelected.CurrentLocation.Latitude), Double.Parse(userSelected.CurrentLocation.Longitude)), Distance.FromMiles(.5) )); string imagePath = new ImageService().SaveImageFromBase64(userSelected.Picture, userSelected.Id); userSelected.PicturePath = imagePath; MapPet.User = userSelected; MapPet.Trip = tripSelected; MapPet.Pins.Add( new Pin { Type = PinType.Place, Label = userSelected.Name, Position = new Position(Double.Parse(userSelected.CurrentLocation.Latitude), Double.Parse(userSelected.CurrentLocation.Longitude)) } ); Name.Text = userSelected.Name; Age.Text = userSelected.LicensePlate; Notes.Text = userSelected.Password; timerFlag = true; TimerEventProcessor(userSelected); }
public static void DeleteFlight(TripModel flight) { foreach (var p in flight.PassengersList) { PassengersViewModel.DeletePassenger(p, flight); } }
public static void EditTrip(TripModel oldTripData, TripModel newTripData) { ChangedTrip = newTripData; TripModel trip = new TripModel(oldTripData.TripNumber, null, newTripData.AirwayCompany, newTripData.Plane, newTripData.TownFrom, newTripData.TownTo, newTripData.DepTime, newTripData.ArrTime, null, null); SaveChangedTrip(trip); }
public async Task <IActionResult> Edit(int id, [FromForm][Bind("Id,CreateUserId,CreateDate,TripStartDate,DepartureCity,DestinationCity,TripEndDate,MaxTravellers,TravelMode,Cost,TripDescription,FileToUpload,CustomPicturePath")] TripModel tripModel) { if (id != tripModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (tripModel.FileToUpload != null) { string fileName = UploadFiles(tripModel.FileToUpload); tripModel.CustomPicturePath = fileName; } _context.Update(tripModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TripModelExists(tripModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tripModel)); }
public ActionResult UpdateTripDetails() { TripModel tripModel = new TripModel(); ViewBag.Title = "Add Trip"; return(View(tripModel)); }
public IHttpActionResult PutTripModel(int id, TripModel tripModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tripModel.Id) { return(BadRequest()); } db.Entry(tripModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TripModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <BusStopDetails> GetStopDataAsync(string StopRef, DateTime timeStart, DateTime timeEnd, bool forceRefresh = false) { //check if its in the buffer OpenArchive gtfsArchive = GetArchiveFromBuffer(this.archiveFileName); if (gtfsArchive == null) { string completePath = this.fileMgr.FilePathRoot + this.archiveFileName; ZipArchive zipFile = this.fileMgr.GetZipFile(this.archiveFileName); gtfsArchive = new OpenArchive(completePath, zipFile); this.bufferedArchives.Add(gtfsArchive); } //get stop id //find stop id from stop name or stop code StopModel stopObj = GetStopFromStopRef(gtfsArchive, StopRef); //get expected trips at stop List <TripTimesModel> trips = GetTripsFromStopId(gtfsArchive, stopObj.stop_id, timeStart, timeEnd); //fill in the details BusStopDetails stopDetails = new BusStopDetails(); stopDetails.StopId = stopObj.stop_id; stopDetails.StopRef = stopObj.stop_code; stopDetails.StopPointName = stopObj.stop_name; stopDetails.busStopX = stopObj.stop_lat; stopDetails.busStopY = stopObj.stop_lon; foreach (TripTimesModel trip in trips) { //details from trip times VehicleJourney vehicleJourney = new VehicleJourney(); TimeSpan startTime = timeStart.TimeOfDay; TimeSpan endTime = timeEnd.TimeOfDay; TimeSpan tripArrivalTime = trip.departure_time; DateTime startOfDate = timeStart.Date; startOfDate = startOfDate.Add(tripArrivalTime); vehicleJourney.TripId = trip.trip_id; vehicleJourney.AimedArrival = startOfDate; vehicleJourney.ConfidenceLevel = 3; //not real time //get more details from trip.csv TripModel tripDetails = GetTripFromTripId(gtfsArchive, trip.trip_id); vehicleJourney.DirrectionAway = tripDetails.direction_id == 1; //get more details from routes.csv RouteModel routeDetails = GetRouteFromRouteId(gtfsArchive, tripDetails.route_id); vehicleJourney.LineRef = routeDetails.route_short_name; stopDetails.IncomingVehicles.Add(vehicleJourney); } stopDetails.IncomingVehicles.Sort(); return(stopDetails); }
public int Update(TripModel model) { Mapper.CreateMap <TripModel, TripMaster>(); TripMaster objInsu = dbContext.TripMasters.SingleOrDefault(m => m.TID == model.TID); objInsu = Mapper.Map(model, objInsu); return(dbContext.SaveChanges()); }
public ActionResult DeleteConfirmed(int id) { TripModel tripModel = db.TripModels.Find(id); db.TripModels.Remove(tripModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Process(TripModel trip) { // Update trip metadata var totalDuration = TimeSpan.FromHours(1); trip.IdleTime = totalDuration; trip.IdleTimeMilliseconds = totalDuration.TotalMilliseconds; }
public TripModel getByID(int?id) { Mapper.CreateMap <TripMaster, TripModel>(); TripMaster objDep = dbContext.TripMasters.SingleOrDefault(m => m.TID == id); TripModel objDepItem = Mapper.Map <TripModel>(objDep); return(objDepItem); }
private void doneButtonClick() { if (TripName == null) { MessageBox.Show("Tên chuyến đi rỗng!!!"); } else if (ImageSource == null) { MessageBox.Show("Image is empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { List <MemberInTripModel> tempMember = new List <MemberInTripModel>(); List <PlaceModel> tempPlace = new List <PlaceModel>(); List <ExpenseModel> tempExpenses = new List <ExpenseModel>(); for (int i = 0; i < MemberList.Count(); i++) { tempMember.Add(MemberList[i]); } for (int i = 0; i < PlaceList.Count(); i++) { tempPlace.Add(PlaceList[i]); } for (int i = 0; i < ExpensesList.Count(); i++) { tempExpenses.Add(ExpensesList[i]); } TripModel newTrip = DatabaseAccess.AddNewTrip(TripName, tempMember, tempExpenses, tempPlace); //Thêm hình if (ImageSource == null) { ImageSource = ""; } var directory = AppDomain.CurrentDomain.BaseDirectory; var locationDirectory = AppDomain.CurrentDomain.BaseDirectory; directory += "Data\\Images\\TripsImage\\" + newTrip.ID + "\\Main"; locationDirectory += "Data\\Images\\TripsImage\\" + newTrip.ID + "\\Location"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } if (!Directory.Exists(locationDirectory)) { Directory.CreateDirectory(locationDirectory); } string fileName = "main.png"; string sourcePath = ImageSource; string targetPath = directory; //Combine file và đường dẫn string sourceFile = System.IO.Path.Combine(sourcePath, ""); string destFile = System.IO.Path.Combine(targetPath, fileName); //Copy file từ file nguồn đến file đích System.IO.File.Copy(sourceFile, destFile, true); MessageBox.Show("Thêm chuyến đi mới thành công!!!"); ICommand BackToHomePage = new UpdateMainViewCommand(MainViewModel); BackToHomePage.Execute((object)"HomePage"); } }
public void PostTripAddInvalidTraveler_Fails() { using (IDbContext idtoFakeContext = new IDTOFakeContext()) using (IUnitOfWork unitOfWork = new UnitOfWork(idtoFakeContext)) { unitOfWork.Repository <Traveler>().Insert(new Traveler { Id = 1, FirstName = "TestFN", LastName = "TestLN", ObjectState = ObjectState.Added }); unitOfWork.Save(); var controller = new TripController(idtoFakeContext); SetupControllerForTests(controller); TripModel m = new TripModel { TravelerId = 50, Origination = "Neverland", Destination = "Montana", TripStartDate = DateTime.Parse("10/2/2012"), TripEndDate = DateTime.Parse("10/2/2013"), MobilityFlag = true, BicycleFlag = true, PriorityCode = "1" }; List <StepModel> steps = new List <StepModel>(); StepModel stepmodel = new StepModel(); stepmodel.StartDate = DateTime.Parse("1/1/2014 10:02"); stepmodel.EndDate = DateTime.Parse("1/1/2014 10:40"); stepmodel.FromName = "Quartz Street"; stepmodel.FromProviderId = (int)Providers.COTA; stepmodel.FromStopCode = "1001"; stepmodel.ModeId = (int)Modes.Bus; stepmodel.RouteNumber = "039"; stepmodel.Distance = (decimal)12.2; stepmodel.ToName = "Slate Run Road"; stepmodel.ToProviderId = (int)Providers.COTA; stepmodel.ToStopCode = "2002"; steps.Add(stepmodel); m.Steps = steps; try { var actionResult = controller.PostTrip(m); Assert.AreEqual(true, false, "Test should have thrown an exception and not executed this line."); } catch (HttpResponseException ex) { Assert.AreEqual(HttpStatusCode.NotFound, ex.Response.StatusCode); } // var response = actionResult as OkNegotiatedContentResult<IEnumerable<Trip>>; // Assert.IsNotNull(response); // var books = response.Content; //Assert.AreEqual(5, books.Count()); // var response = actionResult as NotFoundResult; // Assert.IsNotNull(response); } }
public EditFlightViewModel(TripModel trip) { OldTrip = trip; SelectedTrip = OldTrip; InitializeCollections(); FillInCollections(); SelectedDate = DateTime.Parse(SelectedTrip.Date); SearchText = "Поиск..."; }
public OperationDetails CreateTrip(TripModel item) { var tripPoco = tripMapper.MapEntity(item); var result = tripRepository.Create(tripPoco); unitOfWork.Save(); return(new OperationDetails(true, $"Trip with id {result.Id} was successsfully created", "")); }
public async Task <TripModel> CreateTrip(TripModel newTrip) { var tripDto = _mapper.Map <TripModel, Trip>(newTrip); var newTripDto = await _tripRepository.CreateTrip(tripDto); var result = _mapper.Map <Trip, TripModel>(newTripDto); return(result); }