public void TestGetJourneyByRequest() { Journey journey = null; Guid locationId = Guid.NewGuid(); UserGroup userGroup = UserGroupRepository.Instance.LoadGroupById(1); User traveller = new User(new Email("*****@*****.**"), new UserName("first", "last"), "pwd", userGroup); UserRepository.Instance.SaveUser(traveller); Location origin = new Location("Bangalore", new TravelDate(DateTime.Now.AddDays(1))); Location destination = new Location("Hyderabad", new TravelDate(DateTime.Now.AddDays(10))); journey = new Journey(traveller, origin, destination); IJourneyRepository journeyRepository = JourneyRepository.Instance; journeyRepository.Save(journey); User another = new User(new Email("*****@*****.**"), new UserName("first", "last"), "pwd", userGroup); UserRepository.Instance.SaveUser(another); Request request = new Request(another, new Package(null, null, null), origin, new Location("Hyderabad", new TravelDate(DateTime.Now.AddDays(20)))); RequestRepository.Instance.Save(request); IEnumerable<Journey> journeyList = journeyRepository.Find(request); Assert.True(journeyList.Count() > 0 ); try { Assert.IsTrue(journeyList.Where(a => a.Origin.Place == request.Origin.Place && a.Destination.Place.Equals(request.Destination.Place)).Count() == 1); } finally { JourneyRepository.Instance.Delete(journey); UserRepository.Instance.Delete(traveller); UserRepository.Instance.Delete(another); RequestRepository.Instance.Delete(request); } }
/// <summary> /// Преобразуем массив точек старой поездки к доменному формату /// </summary> /// <param name="fakeJourneyPoints"> /// массив точек старой поездки. должен соответствовать одной поездке /// Массив должен быть упорядочен по времени /// </param> /// <returns>Обект поездки</returns> public Journey Convert(IList<FakeJourney> fakeJourneyPoints) { //преобразуем в наш формат точек var absolutePoints = _mapper.Map<List<AbsolutePoint>>(fakeJourneyPoints); //преобразуем в относительный (координата измеряется относительно предыдущей) формат точек var pointsArray = _absolutePointToRelativeConverter.Convert(absolutePoints); int pointSize = _relativePointToByte.ToByteArray(pointsArray[0]).Length; //размер занимаемый одним элементом byte[] dest = new byte[pointSize * pointsArray.Count]; //полный массив for (int index = 0; index < pointsArray.Count; index++) { var point = pointsArray[index]; _relativePointToByte.ToByteArray(point).CopyTo(dest, index * pointSize); } var journey = new Journey { BinaryVersion = 1, StartPoint = absolutePoints[0], Id = Guid.NewGuid(), Points = dest }; return journey; }
public void TestCreateJourneyForAnExistingUser() { IUserRepository userRepository = UserRepository.Instance; UserRegistration.UserRegistrationService service = new UserRegistrationService(userRepository); User traveller = new User(new Email("*****@*****.**"), new UserName("Test", "User"), "12345", null); service.CreateUser(traveller); Location origin = new Location("London", new TravelDate(DateTime.Now)); Location destination = new Location("Mumbai", new TravelDate(DateTime.Now)); Journey journey = new Journey(traveller, origin, destination); IJourneyRepository journeyRepository = JourneyRepository.Instance; journeyRepository.Save(journey); IList<Journey> journeyList = journeyRepository.FindJourneysByUser(traveller); try { Assert.AreEqual(1,journeyList.Count); } finally { journeyRepository.Delete(journey); userRepository.Delete(traveller); } }
public void MatchRepositoryLoadMatchesListByUserRequest() { UserGroup group=new UserGroup{Id = 1,Name = "Pune"}; User traveller = new User(new Email("*****@*****.**"), null, "password", group); User requestor = new User(new Email("*****@*****.**"), null, "password", group); Package package = new Package("Package", "Weight", "Dimensions"); Location origin = new Location("Origin", new TravelDate(DateTime.Today)); Location destination = new Location("Destination", new TravelDate(DateTime.Today.AddDays(1))); Journey journey = new Journey(traveller, origin, destination); Request request = new Request(requestor, package, origin, destination); UserRepository.Instance.SaveUser(traveller); UserRepository.Instance.SaveUser(requestor); RequestRepository.Instance.Save(request); JourneyRepository.Instance.Save(journey); Match match = new Match(journey, request); IMatchRepository repository = MatchRepository.Instance; IList<Match> matchList = repository.LoadMatchesByUserRequest("*****@*****.**"); try { Assert.AreEqual(1, matchList.Count); } finally { repository.Delete(match); } }
public void should_equate() { const string bank = "Bank"; const string princeRegent = "Prince Regent"; var jny1Memento = new JourneyMemento { Origin = bank, Destination = princeRegent, Fare = short.MinValue }; var jny2Memento = new JourneyMemento { Origin = princeRegent, Destination = bank, Fare = short.MaxValue }; var jny1 = new Journey(jny1Memento); var jny2 = new Journey(jny2Memento); var jny3 = jny1; Assert.That(jny1, Is.EqualTo(jny1)); Assert.That(jny1, Is.Not.EqualTo(jny2)); Assert.That(jny3, Is.Not.EqualTo(jny2)); Assert.That(jny3, Is.EqualTo(jny1)); }
public void TestMatchRepositorySave() { Journey journey = null; Request request = null; User traveller = null; Guid locationId = Guid.NewGuid(); traveller = new User(new Email("*****@*****.**"), new UserName("first", "last"), "pwd", null); UserRepository.Instance.SaveUser(traveller); Location origin = new Location(locationId.ToString(), new TravelDate(DateTime.Now)); Location destination = new Location("TestGetJourneyByRequest Test Destination", new TravelDate(DateTime.Now)); journey = new Journey(traveller, origin, destination); IJourneyRepository journeyRepository = JourneyRepository.Instance; journeyRepository.Save(journey); request = new Request(traveller, new Package(null, null, null), origin, destination); RequestRepository.Instance.Save(request); Match match = new Match(journey, request); MatchRepository.Instance.Save(match); try { Assert.NotNull(match.Id); } finally { MatchRepository.Instance.Delete(match); } }
public IList<Journey> GetJourneys(long startId, long endId) { var journeys = new List<Journey>(); using (var conn = new SqlConnection(ConnString)) { conn.Open(); using (var command = new SqlCommand(GetJourneysBetweenIdsQuery, conn)) { command.Parameters.Add("StartId", SqlDbType.Int).Value = startId; command.Parameters.Add("EndId", SqlDbType.Int).Value = endId; using (var reader = command.ExecuteReader()) { while (reader.Read()) { var journey = new Journey(); journey.JourneyId = (int)reader["JourneyId"]; journey.ArrivalStation = reader["ArrivalStation"].ToString(); journey.DepartureStation = reader["DepartureStation"].ToString(); journey.TravelDate = (DateTime)reader["TravelDate"]; journey.PassengerName = reader["PassengerName"].ToString(); journeys.Add(journey); } } } } return journeys; }
public StoryDatabase(TextAsset[] journeyFiles) { journeys = new Journey[journeyFiles.Length]; for(int i=0; i < journeyFiles.Length; i++) { journeys[i] = new Journey(journeyFiles[i]); }//for }
public void GivenMichaelTravelsFromOriginToDestination(string origin, string destination) { Journey journey = new Journey( _stations.Find(x => x.Name == origin), _stations.Find(x => x.Name == destination) ); _michael.PerformJourney(journey); }
public void should_have_no_fare() { const short fare = 10; var journey = new Journey(); journey.AssignFare(od => fare); Assert.That(OriginDestination.HasNoJourney(journey.Project().OriginDestination), Is.True); Assert.That(journey.Project().Fare, Is.EqualTo(0)); }
/****************************************************************************************************/ // METHODS - PERSISTENCE /****************************************************************************************************/ // Concatenates all data under the user class and returns it as one long string // Each data entry is separated by a delimiter, % public void Clear() { _ticketExpiry = 0; _smsLog.Clear(); _journeyLog.Clear(); _userStatus = USER_STATUS.inactive; _location = null; _journeyPlan = new Journey(null, null, null, -1, -1); _account = 0; }
public void PassengerChargedForReturnJourneyZoneA() { decimal zoneAReturnJourneyFare = Prices.ReturnZoneA; Journey journey1 = new Journey(zoneAStation1, zoneAStation2); Journey journey2 = new Journey(zoneAStation2, zoneAStation1); passenger.PerformJourney(journey1); passenger.PerformJourney(journey2); Assert.AreEqual(zoneAReturnJourneyFare, passenger.GetJourney(2).Cost); }
private void btnWalk_Click(object sender, EventArgs e) { Journey jn = new Journey(); jn.JouneyType = 1; db.JourneyToSchool.Journeys.Add(jn); AddPanelUc add = new AddPanelUc(); panel1.Controls.Clear(); panel1.Controls.Add(add); }
public void Save(Journey journey) { try { _tfrContext.Journey.Add(journey); _tfrContext.SaveChanges(); } catch (Exception e) { log.Fatal($"Error in saving journey to data base. Exception = {e}"); } }
public void TestIfEventsAreSubscribedTo() { var requestRepository = new Mock<IRequestRepository>(); var journeyRepository = new Mock<IJourneyRepository>(); Request request = new Request(); Journey journey = new Journey(); requestRepository.Setup(a => a.Save(request)).Raises(a => a.RequestCreated += null, RequestCreatedEventArgs.Empty); journeyRepository.Setup(a => a.Save(journey)).Raises(a => a.JourneyCreated += null, new JourneyCreatedEventArgs()); JourneyRequestMatcher matcher = new JourneyRequestMatcher(requestRepository.Object, journeyRepository.Object); matcher.EventPublisher = new EventPublisher(); //TODO: Fix later }
public void BankToBankFare() { var bank = "Bank"; var journey = new Journey { Origin = bank, Destination = bank }; var repositoryMockery = new Mock <IFareRepository>(); var fareService = new FareService(repositoryMockery.Object); fareService.AssignFare(journey); repositoryMockery.Verify(r => r.GetFare(bank, bank)); }
public MockFareAlertRepository(ICityRepository cityRepository) { var passenger = new Passenger(36); var fareConstraint = new FareBound(new Fare(1000), new Fare(4000), FareBoundType.Inclusive, FareBoundType.Inclusive); var journey = new Journey(cityRepository.Get("BLR"), cityRepository.Get("MAA"), DateTime.Now.AddDays(2), DateTime.Now.AddDays(3), new List <Passenger>() { passenger }); var fareAlert = new FareAlert(journey, fareConstraint, "SMTWT__".ToDaysOfWeek()); Add(fareAlert); }
public static int GetNumberOfLegs(this Journey journey) { int num = 0; if (journey.Segments != null) { for (int index = 0; index < journey.Segments.Length; ++index) { num += journey.Segments[index].Legs.Length; } } return(num); }
public static Journey <T> PreviousSpecial <T>(this Journey <T> j) where T : IJourneyMetric <T> { while (j.PreviousLink != null) { j = j.PreviousLink; if (j.SpecialConnection) { return(j); } } return(j); // We've found the root }
public static List <string> GetClassesOfService(this Journey journey) { List <string> stringList = new List <string>(); if (journey.Segments != null) { foreach (Segment segment in journey.Segments) { stringList.Add(segment.GetClassOfService()); } } return(stringList); }
public ActionResult Create([Bind(Include = "JourneyId,OriginLocationCode,DestinationLocationCode,OperatingCompanyId,StartDateAndTime,EndDateAndTime,OtherDetails")] Journey journey) { if (ModelState.IsValid) { service.CreateJourney(journey); return(RedirectToAction("Index")); } ViewBag.DestinationLocationCode = new SelectList(locationService.GetAllLocations(), "LocationCode", "LocationName", journey.DestinationLocationCode); ViewBag.OperatingCompanyId = new SelectList(operatingCompanyService.GetAllOperatingCompanies(), "OperatingCompanyId", "OperatingCompanyName", journey.OperatingCompanyId); ViewBag.OriginLocationCode = new SelectList(locationService.GetAllLocations(), "LocationCode", "LocationName", journey.OriginLocationCode); return(View(journey)); }
public IActionResult Update(string id, Journey journeyIn) { var journey = _sampleService.Get(id); if (journey == null) { return(NotFound()); } _sampleService.Update(id, journeyIn); return(NoContent()); }
public void Delete(Journey journey) { try { _tfrContext.Journey.Remove(journey); _tfrContext.SaveChanges(); } catch (Exception e) { log.Error($"Cannot initiate Delete from data base. Error message: {e}"); } }
public Journey AddJourney(Journey journey, List <JourneyAsset> journeyAssets, List <JourneyAssetDriver> journeyAssetDrivers, List <JourneyAssetExternalPassenger> journeyAssetExternalPassengers, JourneyRoute journeyRoute) { IHttpRestRequest request = GetRequest(APIControllerRoutes.JourneysController.ADDJOURNEY, HttpMethod.Put); request.AddJsonBody(journey); request.AddJsonBody(journeyAssets); request.AddJsonBody(journeyAssetDrivers); request.AddJsonBody(journeyAssetExternalPassengers); request.AddJsonBody(journeyRoute); IHttpRestResponse <Journey> response = Execute <Journey>(request, 1); return(response.Data); }
public async Task SearchByJourneyByName() { var results = await Journey.GetAllAsync(_azureSql); Assert.True(results.Any()); var selected = results.FirstOrDefault(); var checkid = await Journey.SearchByJourneyNameAsync(selected.JourneyName, _azureSql); var selectedChecked = checkid.FirstOrDefault(); Assert.Equal(selected.JourneyName, selectedChecked.JourneyName); }
public static void GetPriceDetails(Journey journey) { IsPriceDetailsCompleted = false; string xml = JourneyParsing.GetPriceDetails(journey); var client = new ServiceSoapClient(); client.StrIsletAsync(xml, Global.Authorization); client.StrIsletCompleted += (c, e) => { string xmlResult = e.Result; PopulatePriceDetails(xmlResult); }; }
public static int Task2(List <string> path) { var journey = new Journey(); var max = int.MinValue; foreach (var stage in path) { journey.Travel(stage); max = Math.Max(max, journey.DistanceFromStart()); } return(max); }
public async Task <IActionResult> Create([Bind("Idjourney,DepartureTime,Regularly,Smoker,DeparturePointPostcode,UserIdUser")] Journey journey) { if (ModelState.IsValid) { _context.Add(journey); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DeparturePointPostcode"] = new SelectList(_context.DeparturePoint, "Postcode", "Postcode", journey.DeparturePointPostcode); ViewData["UserIdUser"] = new SelectList(_context.User, "IdUser", "EMail", journey.UserIdUser); return(View(journey)); }
private static List <FieldLookupValue> ConvertSkills(Journey journey) { var lookupValuesSkills = new List <FieldLookupValue>(); foreach (Skill element in journey.Skills) { lookupValuesSkills.Add(new FieldLookupValue { LookupId = element.Id }); } return(lookupValuesSkills); }
public async Task <Journey> AddJourneyAsync(Journey journey, List <JourneyAsset> journeyAssets, List <JourneyAssetDriver> journeyAssetDrivers, List <JourneyAssetExternalPassenger> journeyAssetExternalPassengers, JourneyRoute journeyRoute) { IHttpRestRequest request = GetRequest(APIControllerRoutes.JourneysController.ADDJOURNEY, HttpMethod.Put); request.AddJsonBody(journey); request.AddJsonBody(journeyAssets); request.AddJsonBody(journeyAssetDrivers); request.AddJsonBody(journeyAssetExternalPassengers); request.AddJsonBody(journeyRoute); IHttpRestResponse <Journey> response = await ExecuteAsync <Journey>(request, 1).ConfigureAwait(false); return(response.Data); }
public ActionResult Clone([Bind(Include = "journey_id,journey1,departure,destination,car_id,date,distance")] Journey journey) { if (ModelState.IsValid) { db.Journeys.Add(journey); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.car_id = new SelectList(db.Cars, "car_id", "name", journey.car_id); ViewBag.departure = new SelectList(db.Points, "point_id", "point1", journey.departure); ViewBag.destination = new SelectList(db.Points, "point_id", "point1", journey.destination); return(View(journey)); }
public async Task <IActionResult> Create([Bind("JourneyId,BusId,RouteId,DeportingTime,AffectDistance,CarrierCompanyCosts,StartTime,EndTime")] Journey journey) { if (ModelState.IsValid) { _context.Add(journey); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BusId"] = new SelectList(_context.Bus, "BusId", "BusModel", journey.BusId); ViewData["RouteId"] = new SelectList(_context.Broute, "RouteId", "EndPoint", journey.RouteId); return(View(journey)); }
//Fare calculation is done on the basis of FromZone, ToZone and Journey day and time private int CalculateFare(Journey journey) { string time = journey.StartDateTime.ToString("HH:mm"); string dayType = GetDayType(journey.StartDateTime.DayOfWeek.ToString().ToLower()); ZoneType zoneType = journey.FromZone == journey.ToZone ? ZoneType.Intra : ZoneType.Inter; bool isPeakFare = dbContext.PeakTimings.Where(x => x.Day == dayType && x.ZoneType == zoneType && TimeSpan.Parse(time) >= TimeSpan.Parse(x.StartTime) && TimeSpan.Parse(time) <= TimeSpan.Parse(x.EndTime)).Any(); Fare item = dbContext.FareDetails.FirstOrDefault(x => x.FromZone == journey.FromZone && x.ToZone == journey.ToZone); return(isPeakFare ? item.PeakFare : item.DefaultFare); }
public void Execute(AddJourneyWithLiftsCommand command) { var routeDistance = new Distance(command.RouteDistance, DistanceUnit.Kilometer); var journey = new Journey(command.JourneyId, command.DateOfOccurrence, routeDistance, _eventPublisher); foreach (var lift in command.Lifts) { var liftDistance = new Distance(lift.LiftDistance, DistanceUnit.Kilometer); var personId = GetOrAddPersonWithName(lift.PersonName); journey = journey.AddLift(personId, liftDistance); } _repositories.Store(journey); }
public static void GetSeatStates(Journey journey) { IsSeatStatesCompleted = false; string xml = BusParsing.GetSeatStates(journey); var client = new ServiceSoapClient(); client.StrIsletAsync(xml, Global.Authorization); client.StrIsletCompleted += (s, e) => { string xmlResult = e.Result; PopulateSeatStates(xmlResult); }; }
public void Save(Journey journey) { using (var sqlConnection = new SqlConnection(_connectionString)) { sqlConnection.Open(); string query = "EXEC [dbo].[SaveStations] @StartDatetime, @Duration, @ArrivalDatetime"; var sqlCommand = new SqlCommand(query, sqlConnection); sqlCommand.Parameters.AddWithValue("@StartDateTime", journey.StartDateTime); sqlCommand.Parameters.AddWithValue("@Duration", journey.Duration); sqlCommand.Parameters.AddWithValue("@ArrivalDatetime", journey.ArrivalDateTime); sqlCommand.ExecuteNonQuery(); } }
public JourneyViewModel(Journey journeyInfo, NotificationApplicationCompletionProgress progress) { NotificationId = journeyInfo.NotificationId; IsStateOfExportCompleted = progress.HasStateOfExport; IsStateOfImportCompleted = progress.HasStateOfImport; AreTransitStatesCompleted = progress.HasTransitState; IsCustomsOfficeCompleted = progress.HasCustomsOffice; StateOfExportData = journeyInfo.TransportRoute.StateOfExport; TransitStates = journeyInfo.TransportRoute.TransitStates.ToList(); StateOfImportData = journeyInfo.TransportRoute.StateOfImport; EntryCustomsOffice = journeyInfo.EntryCustomsOffice.CustomsOfficeData ?? new CustomsOfficeData(); ExitCustomsOffice = journeyInfo.ExitCustomsOffice.CustomsOfficeData ?? new CustomsOfficeData(); }
public void TranslateJourney_SimpleJourney_CorrectTranslation() { var depDate = new DateTime(2019, 06, 19, 10, 00, 00).ToUniversalTime(); var tdb = new TransitDb(0); var writer = tdb.GetWriter(); var stop0 = writer.AddOrUpdateStop("https://example.org/stop0", 0, 0); var stop1 = writer.AddOrUpdateStop("https://example.org/stop1", 1, 1); var stop2 = writer.AddOrUpdateStop("https://example.org/stop2", 2, 2); var trip0 = writer.AddOrUpdateTrip("https://example.org/trip0", new[] { new Attribute("headsign", "Oostende") }); var conn0 = writer.AddOrUpdateConnection(stop0, stop1, "https://example.org/conn1", depDate.AddMinutes(-10), 10 * 60, 0, 0, trip0, 0); writer.Close(); var con = tdb.Latest.ConnectionsDb; var connection = con.Get(conn0); var genesis = new Journey <TransferMetric>(stop0, depDate.ToUnixTime(), TransferMetric.Factory, Journey <TransferMetric> .EarliestArrivalScanJourney); var journey0 = genesis.ChainForward(connection); var journey1 = journey0.ChainSpecial( Journey <TransferMetric> .OTHERMODE, depDate.AddMinutes(15).ToUnixTime(), stop2, new TripId(uint.MaxValue, uint.MaxValue)); var state = new State(new List <Operator> { new Operator("test", tdb, null, 0, null, null) }, null, null, null); var cache = new CoordinatesCache(new CrowsFlightTransferGenerator(), false); var translated = state.Operators.GetFullView().Translate(journey1, cache); Assert.Equal("https://example.org/stop0", translated.Segments[0].Departure.Location.Id); Assert.Equal("https://example.org/stop1", translated.Segments[0].Arrival.Location.Id); Assert.Equal("https://example.org/trip0", translated.Segments[0].Vehicle); Assert.Equal("https://example.org/stop1", translated.Segments[1].Departure.Location.Id); Assert.Equal("https://example.org/stop2", translated.Segments[1].Arrival.Location.Id); Assert.Null(translated.Segments[1].Vehicle); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Journey journey = db.Find(id); if (journey == null) { return(HttpNotFound()); } return(View(journey)); }
protected void btnSave_Click(object sender, EventArgs e) { if (drSelectionCriteria.SelectedIndex == 0) { divError.Visible = true; txtError.InnerHtml = "Please Select View Or Update!"; } else { Journey journeyPlan = datacontext.Journeys.Where(n => n.regID == int.Parse(Request.QueryString["Id"])).FirstOrDefault(); if (journeyPlan.regID == null) { journeyPlan.regID = int.Parse(Request.QueryString["Id"]); datacontext.Journeys.InsertOnSubmit(journeyPlan); datacontext.SubmitChanges(); } else { var regid = datacontext.UserRegistrations.Where(n => n.ID == int.Parse(Request.QueryString["Id"])).FirstOrDefault(); journeyPlan.regID = regid.ID; journeyPlan.HIVTesting = ddrHIVTesting.SelectedItem.Text; journeyPlan.HIVSelfScreening = drHIVSelfScreening.SelectedItem.Text; journeyPlan.CondomsSTIScreening = drCondomsSTIScreening.SelectedItem.Text; journeyPlan.PregnancyTesting = drPregnancyTesting.SelectedItem.Text; journeyPlan.EmergencyContraception = drEmergencyContraception.SelectedItem.Text; journeyPlan.VendingMachines = ddrVendingMachines.SelectedItem.Text; journeyPlan.PeerEducation = drPeerEducation.SelectedItem.Text; journeyPlan.ComprehensiveSexualityEducation = ddrComprehensiveSexualityEducation.SelectedItem.Text; journeyPlan.IndividualAndGroupSupport = ddrIndividualAndGroupSupport.SelectedItem.Text; journeyPlan.PrepDemandCreation = ddrPrepDemandCreation.SelectedItem.Text; journeyPlan.SRHKnowledge = ddrSRHKnowledge.SelectedItem.Text; journeyPlan.MentalHealthSupport = ddrMentalHealthSupport.SelectedItem.Text; journeyPlan.SupportAccessSocialGrants = ddrSupportAccessSocialGrants.SelectedItem.Text; journeyPlan.DignityPacks = ddrDignityPacks.SelectedItem.Text; journeyPlan.AcademicSupport = ddrAcademicSupport.SelectedItem.Text; journeyPlan.ReturnToSchoolSupport = ddrReturnToSchoolSupport.SelectedItem.Text; journeyPlan.ECDVouchers = ddrECDVouchers.SelectedItem.Text; journeyPlan.EconomicStrengthening = ddrEconomicStrengthening.SelectedItem.Text; journeyPlan.WholeSchoolDevelopment = ddrWholeSchoolDevelopment.SelectedItem.Text; journeyPlan.MenDialoguesGenderNorms = ddrMenDialoguesGenderNorms.SelectedItem.Text; journeyPlan.YouthLeadership = ddrYouthLeadership.SelectedItem.Text; datacontext.SubmitChanges(); divSuccess.Visible = false; txtSuccess.InnerHtml = "Journey Plan Successfully Updated"; } } }
private Journey ProcessJourneyEnd(IStation station) { var journey = new Journey { Date = _dateTimeProvider.Now, From = CurrentJourneyStartFrom, To = station, Cost = CalculateCostForCurrentJourney(station) }; ClearCurrentJourney(journey); return(journey); }
private State createStateFor(int difficulty) { ArrayList topics = new ArrayList(); Topic topic = new Topic(MAX_TOPIC_DIFFICULTY, "addition"); topics.Add(topic); ArrayList journeys = new ArrayList(); Journey journey = new Journey(topics); journeys.Add(journey); Grade grade = new Grade(journeys); return(new State(grade, journey, topic, difficulty, DisplayTypeEnum.circleDisplay)); }
private ReportRowViewModel GenerateRow(Journey journey, string country) { var invoices = journey.Invoices.ToList(); var row = new ReportRowViewModel { AmountOfPeople = journey.AmountOfPeople, EndDate = journey.EndDate, FinalPlace = journey.FinalPlace, StartDate = journey.StartDate, RegistratioNumbers = journey.JourneyVehicles.Select(v => v.Vehicle.RegistrationNumber).ToList(), TotalDistance = journey.TotalDistance, CountryDistance = journey.Countries.Single(c => c.Name == country).Distance, InvoicesDates = invoices.Select(i => i.Date).ToList(), InvoicesAmounts = invoices.Select(i => (Math.Round(i.Amount, 2), i.Type)).ToList(), ExchangeRates = invoices.Select(i => GetRateBetweenCurrencies(i.Date, i.Type, _countriesHelper.GetCurrencyForCountry(country))).ToList() }; row.PartsOfCountryInInvoicesAmounts = invoices.Select(i => ( Math.Round(i.Amount * row.CountryDistance / row.TotalDistance, 2), i.Type ) ).ToList(); row.PartOfCountryInInvoicesAmountInCurrency = Math.Round(invoices.Select((invoice, index) => { var result = CalculateBetweenCurrencies(row.PartsOfCountryInInvoicesAmounts[index].Item1, invoice.Date, invoice.Type, _countriesHelper.GetCurrencyForCountry(country)); //poprawka formuly: nie dzialalo jak faktura byla w EUR a przeliczalo na HRK albo DKK: if (invoice.Type == CurrencyType.EUR && (CountriesHelper.HrkCurrencyCountries.Contains(country) || CountriesHelper.DkkCurrencyCountries.Contains(country))) { result = CalculateBetweenCurrencies(result, invoice.Date, CurrencyType.PLN, _countriesHelper.GetCurrencyForCountry(country)); row.ExchangeRates[index] = GetRateBetweenCurrencies(invoice.Date, CurrencyType.PLN, _countriesHelper.GetCurrencyForCountry(country)); } return(result); } ).Sum(), 2); row.NettoResult = Math.Round( row.PartOfCountryInInvoicesAmountInCurrency / _countriesHelper.GetTaxFactorForCountry(country), 2 ); return(row); }
public void GetOneJourneyBysearch() { Journey journey = journeyClassic4; journey.ID = 0; journey.FreeSeat = 10; using (EFJourneyMapper mapper = new EFJourneyMapper(CONNECTION_STRING)) { journey = mapper.AddorUpdate(journey); Expression <Func <Journey, bool> > expression = j => j.Description == journey.Description && j.Driver == journey.Driver; Assert.AreEqual(journey.ID, mapper.FindBy(expression).First().ID); } }
public void DailyCapZoneB() { decimal dailyCapZoneB = Prices.DailyCapZoneB; Journey journey1 = new Journey(zoneAStation1, zoneBStation1); Journey journey2 = new Journey(zoneBStation1, zoneAStation1); Journey journey3 = new Journey(zoneAStation1, zoneBStation1); Journey journey4 = new Journey(zoneBStation1, zoneAStation1); passenger.PerformJourney(journey1); passenger.PerformJourney(journey2); passenger.PerformJourney(journey3); passenger.PerformJourney(journey4); Assert.AreEqual(2.5m, passenger.GetJourney(3).Cost); Assert.AreEqual(0.0m, passenger.GetJourney(4).Cost); }
public void should_equate() { const string bank = "Bank"; const string princeRegent = "Prince Regent"; var accountId = Guid.NewGuid(); var jny1 = new Journey(accountId, bank, princeRegent); var jny2 = new Journey(accountId, princeRegent, bank); var jny3 = jny1; Assert.That(jny1, Is.EqualTo(jny1)); Assert.That(jny1, Is.Not.EqualTo(jny2)); Assert.That(jny3, Is.Not.EqualTo(jny2)); Assert.That(jny3, Is.EqualTo(jny1)); }
private List<Journey> _journeyLog; // stores the bus stops hopped on from and hopped off to and the corresponding bus name taken (past) /****************************************************************************************************/ // CONSTRUCTOR /****************************************************************************************************/ public User(string name, string mobileNum, float account, string creditCardNum, PAYMENT_MODE paymentMode1, PAYMENT_MODE paymentMode2, string password) { _name = name; _mobileNum = mobileNum; _account = account; _creditCardNum = creditCardNum; _paymentMode1 = paymentMode1; _paymentMode2 = paymentMode2; _ticketExpiry = 0; _journeyPlan = new Journey(null, null, null, -1, -1); _userStatus = USER_STATUS.inactive; _location = null; _password = password; _smsLog = new List<string>(); _journeyLog = new List<Journey>(); }
public static List<Timetable> LoadAllTimetables() { var timetableFiles = new List<Timetable>(); var fileList = Directory.GetFiles(Options.workingDirectory + "\\Timetables"); foreach (string filename in fileList) { // Reasds the CSV using the method in this class. // The 'false' argument prevents readCSV from adding the directory path, // as it is already in the filename string. var splitCsv = readCSV(filename, true); // Split the timetable name into parts to be processed var timetableNameParts = Path.GetFileName(filename).Split('.'); // Initialise a new timetable Timetable thisTimetable = new Timetable(); // Set the route name and the specific sub-route to the values in the filename thisTimetable.routeName = timetableNameParts[0]; thisTimetable.subRoute = timetableNameParts[1]; // Look at the filename for which days it runs and use the sub to input these ProcessDaysRun(thisTimetable, timetableNameParts[2]); // For each line of the CSV except for the first line containing stop IDs for (int i = 1; i < splitCsv.Count; i++) { // Initialise a journey Journey journey = new Journey(); var row = splitCsv[i]; for (int j = 0; j < row.Length; j++) { if (Validation.ValidTime(row[j])) { JourneyStop stop = new JourneyStop(); stop.stopID = splitCsv[0][j]; int thisTime = int.Parse(splitCsv[i][j]); stop.stopMinuteTime = Time.ConvertToMinTime(thisTime); journey.stops.Add(stop); } } thisTimetable.journeys.Add(journey); } timetableFiles.Add(thisTimetable); } return timetableFiles; }
public Journey CreateJourneyForExactPorts(string[] ports) { var journey = new Journey(); try { for (var i = 0; i < ports.Length - 1; i++) { journey.Routes.Add(_routeRepository.GetRoute(ports[i], ports[i + 1])); } } catch (ArgumentException ae) { throw ae; } return journey; }
public void should_be_bank_to_bank() { const string bank = "Bank"; const short fare = 10; var journey = new Journey(); var msg1 = new DeviceTappedCommand(journey.AccountId, bank, "rail"); var msg2 = new DeviceTappedCommand(journey.AccountId, bank, "rail"); journey.RecieveTap(msg2); journey.RecieveTap(msg1); journey.AssignFare(od => fare); Assert.That(journey.Project().OriginDestination, Is.EqualTo(OriginDestination.HereToHere(bank))); Assert.That(journey.Project().Fare, Is.EqualTo(10)); }
public void ShouldUpdateMatchStatusAndAcceptingUserInRequest() { UserGroup group = new UserGroup { Id = 1, Name = "Pune" }; User user1 = new User(new Email("*****@*****.**"), null, "password", group); User user2 = new User(new Email("*****@*****.**"), null, "password", group); Package package = new Package("Package", "Weight", "Dimensions"); Location origin = new Location("Origin", new TravelDate(DateTime.Today)); Location destination = new Location("Destination", new TravelDate(DateTime.Today.AddDays(1))); Journey journey = new Journey(user1, origin, destination); Request request = new Request(user2, package, origin, destination); UserRepository.Instance.SaveUser(user1); UserRepository.Instance.SaveUser(user2); RequestRepository.Instance.Save(request); JourneyRepository.Instance.Save(journey); Match match = new Match(journey, request); IMatchRepository matchRepository = MatchRepository.Instance; IList<Match> matchList = matchRepository.LoadMatchesByUserRequest("*****@*****.**"); foreach (Match myMatch in matchList) { myMatch.Status = MatchStatus.Accepted; myMatch.Request.AcceptingUser = user1; } matchRepository.UpdateMatches(matchList); IList<Match> updatedMatchList = matchRepository.LoadMatchesByUserRequest("*****@*****.**"); try { Assert.AreEqual(1, matchList.Count); foreach (Match myMatch in updatedMatchList) { Assert.AreEqual(MatchStatus.Accepted,myMatch.Status); Assert.AreEqual(myMatch.Request.AcceptingUser,user1); } } finally { matchRepository.Delete(match); UserRepository.Instance.Delete(user1); UserRepository.Instance.Delete(user2); } }
public void should_be_sortable() { const string kingsCross = "Kings Cross"; const string bank = "Bank"; const string princeRegent = "Prince Regent"; const short fare = 10; var accountId = Guid.NewGuid(); var jny1 = new Journey(accountId, kingsCross, bank); var jny2 = new Journey(accountId, bank, princeRegent); var jny3 = new Journey(accountId, princeRegent, bank); jny1.AssignFare((o, d) => fare); jny2.AssignFare((o, d) => fare); jny3.AssignFare((o, d) => fare); var jourenys = new List<Journey>(new[] {jny2, jny3, jny1}); jourenys.Sort(); Assert.That(jourenys.First().Export().Origin, Is.EqualTo(kingsCross)); Assert.That(jourenys.First().Export().Destination, Is.EqualTo(bank)); Assert.That(jourenys.First().Export().Fare, Is.EqualTo(10)); Assert.That(jourenys.First().Export().AccountId, Is.EqualTo(accountId)); Assert.That(jourenys.First().Export().JourneyId, Is.Not.EqualTo(Guid.Empty)); Assert.That(jourenys.ElementAt(1).Export().Origin, Is.EqualTo(bank)); Assert.That(jourenys.ElementAt(1).Export().Destination, Is.EqualTo(princeRegent)); Assert.That(jourenys.ElementAt(1).Export().Fare, Is.EqualTo(10)); Assert.That(jourenys.ElementAt(1).Export().AccountId, Is.EqualTo(accountId)); Assert.That(jourenys.ElementAt(1).Export().JourneyId, Is.Not.EqualTo(Guid.Empty)); Assert.That(jourenys.Last().Export().Origin, Is.EqualTo(princeRegent)); Assert.That(jourenys.Last().Export().Destination, Is.EqualTo(bank)); Assert.That(jourenys.Last().Export().Fare, Is.EqualTo(10)); Assert.That(jourenys.Last().Export().AccountId, Is.EqualTo(accountId)); Assert.That(jourenys.Last().Export().JourneyId, Is.Not.EqualTo(Guid.Empty)); }
public void should_demonstrate_tinkering() { const string outerMongolia = "Outer Mongolia"; const string bank = "Bank"; const short fare = 10; var memento = new JourneyMemento { AccountId = Guid.NewGuid(), Origin = bank, Destination = bank, Fare = 0 }; var journey = new Journey(memento); memento.Destination = outerMongolia; journey.AssignFare((origin, destination) => fare); var projection = journey.Project(); Assert.That(projection.Destination, Is.EqualTo(outerMongolia)); }
public void should_be_sortable() { const string bank = "Bank"; const string princeRegent = "Prince Regent"; const short fare = 10; var jny1Memento = new JourneyMemento { Origin = bank, Destination = princeRegent, Fare = 0 }; var jny2Memento = new JourneyMemento { Origin = princeRegent, Destination = bank, Fare = 0 }; var jny1 = new Journey(jny1Memento); var jny2 = new Journey(jny2Memento); jny1.AssignFare((o, d) => fare); jny2.AssignFare((o, d) => fare); var journeys = new List<Journey>(new[] {jny2, jny1}); journeys.Sort(); Assert.That(journeys.First().Project().Origin, Is.EqualTo(bank)); Assert.That(journeys.First().Project().Destination, Is.EqualTo(princeRegent)); Assert.That(journeys.First().Project().Fare, Is.EqualTo(10)); Assert.That(journeys.Last().Project().Origin, Is.EqualTo(princeRegent)); Assert.That(journeys.Last().Project().Destination, Is.EqualTo(bank)); Assert.That(journeys.Last().Project().Fare, Is.EqualTo(10)); }
public void TestFindRequestHavingMatchingLocationButFromADifferentGroup() { Journey journey = null; UserGroup group = UserGroupRepository.Instance.LoadGroupById(1); User requestingUser = new User(new Email("*****@*****.**"), new UserName("first", "last"), "pwd", group); UserRepository.Instance.SaveUser(requestingUser); Location origin = new Location("Bangalore", new TravelDate(DateTime.Now.AddDays(1))); Request request = new Request(requestingUser, new Package(null, null, null), origin, new Location("Hyderabad", new TravelDate(DateTime.Now.AddDays(10)))); RequestRepository.Instance.Save(request); UserGroup group2 = UserGroupRepository.Instance.LoadGroupById(2); User traveller = new User(new Email("*****@*****.**"), new UserName("first", "last"), "pwd", group2); UserRepository.Instance.SaveUser(traveller); Location destination = new Location("Hyderabad", new TravelDate(DateTime.Now.AddDays(20))); journey = new Journey(traveller, origin, destination); IJourneyRepository journeyRepository = JourneyRepository.Instance; journeyRepository.Save(journey); IEnumerable<Request> requests = RequestRepository.Instance.Find(journey); try { Console.WriteLine("####" + requests.Count()); Assert.True(requests.Count() == 0); } finally { RequestRepository.Instance.Delete(request); JourneyRepository.Instance.Delete(journey); UserRepository.Instance.SaveUser(requestingUser); UserRepository.Instance.SaveUser(traveller); } }
public void should_include_fields() { const string bank = "Bank"; const short fare = 10; var memento = new JourneyMemento { AccountId = Guid.NewGuid(), Origin = bank, Destination = bank, Fare = 0 }; var journey = new Journey(memento); journey.AssignFare((origin, destination) => fare); var projection = journey.Project(); Assert.That(projection.AccountId, Is.EqualTo(memento.AccountId)); Assert.That(projection.Origin, Is.EqualTo(bank)); Assert.That(projection.Destination, Is.EqualTo(bank)); Assert.That(projection.Fare, Is.EqualTo(10)); }
private TravelInsight ExtractInsight(Journey journey) { var insight = new TravelInsight() { InsightDate = journey.TravelDate.Date, InsightText = "Some useful insight", PassengerName = journey.PassengerName }; return insight; }
// adds a journey to the log public void AddJourney(Journey journey) { _journeyLog.Add(journey); }
public void fly(int x, int y) { Journey j = new Journey(); j.name = "fly"; j.x = x; j.y = y; _path.Add(j); }
public void ride_taxi(int x, int y) { Journey j = new Journey(); j.name = "ride_taxi"; j.x = x; j.y = y; _path.Add(j); }