Esempio n. 1
0
        public async Task <TripDTO> GetById(TripId id)
        {
            var trip = await this._repo.GetByIdAsync(id);

            if (trip == null)
            {
                return(null);
            }

            return(_mapper.DomainToDTO(trip));
        }
        public override int GetHashCode()
        {
            var hashCode = AgencyId.GetHashCode();

            hashCode = (hashCode * 397) ^ RouteId.GetHashCode();
            hashCode = (hashCode * 397) ^ RouteType.GetHashCode();
            hashCode = (hashCode * 397) ^ TripId.GetHashCode();
            hashCode = (hashCode * 397) ^ StopId.GetHashCode();

            return(hashCode);
        }
Esempio n. 3
0
        public void GetById()
        {
            var tripServiceMock = new Mock <ITripService> ();
            var pathServiceMock = new Mock <IPathService> ();

            string lineID            = "Line:1";
            string pathID            = "Path:1";
            string tripDepartureTime = "20:12:10";

            var trip = new Trip(lineID, pathID, tripDepartureTime);

            var tripDTO = new TripDTO(trip.Id.AsGuid(), new LineId(lineID), new PathId(pathID), tripDepartureTime);

            var tripID = new TripId(trip.Id.AsGuid());

            tripServiceMock.Setup(_ => _.GetById(tripID)).ReturnsAsync(tripDTO);

            var controller = new TripController(tripServiceMock.Object, pathServiceMock.Object);

            var actual = controller.GetById(trip.Id.AsGuid());

            Assert.Equal(tripDTO, actual.Result.Value);
        }
            public TravellingTimeMinimizer Add(Journey <TravellingTimeMinimizer> journey, StopId currentLocation, ulong currentTime, TripId currentTripId,
                                               bool currentIsSpecial)
            {
                var totalTimeWalking   = _totalTimeWalking;
                var totalTimeInVehicle = _totalTimeInVehicle;
                var smallestTransfer   = _smallestTransfer;

                var journeyTime = (uint)(journey.ArrivalTime() - journey.DepartureTime());

                if (journey.SpecialConnection && journey.Connection.Equals(OTHERMODE))
                {
                    totalTimeWalking += journeyTime;
                }
                else if (journey.SpecialConnection && journey.Connection.Equals(OTHERMODE))
                {
                    smallestTransfer = Math.Min(smallestTransfer, journeyTime);
                }
                else if (!journey.SpecialConnection)
                {
                    // We simply are travelling in a vehicle
                    totalTimeInVehicle += journeyTime;
                }

                return(new TravellingTimeMinimizer(totalTimeWalking, totalTimeInVehicle, smallestTransfer));
            }