コード例 #1
0
        public async Task <List <TripDTO> > GetAll()
        {
            var tripList = await this._repo.GetAllAsync();

            var tripDTOlist = new List <TripDTO> ();

            foreach (var trip in tripList)
            {
                TripDTO tripDTO = _mapper.DomainToDTO(trip);

                tripDTOlist.Add(tripDTO);
            }

            foreach (var tripDTO in tripDTOlist)
            {
                tripDTO.nodePassageListDTO.Sort(delegate(NodePassageDTO x, NodePassageDTO y){
                    var xSec = TimeUtils.fromStringToSec(x.passageTime);
                    var ySec = TimeUtils.fromStringToSec(y.passageTime);
                    return(xSec.CompareTo(ySec));
                });
            }

            return(tripDTOlist);
        }
コード例 #2
0
ファイル: TripMapperTest.cs プロジェクト: TiagoFBM/isep
        public void DTOtoDomain()
        {
            var mapper = new TripMapper();

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

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

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

            var actual = mapper.DomainToDTO(trip);

            Assert.True(expected.Equals(actual));
        }