DomainDrivenDelivery.Interfaces.Booking.Facade.DTOAssembler.toDTO C# (CSharp) Method

toDTO() static private method

static private toDTO ( Cargo cargo ) : CargoRoutingDTO
cargo Cargo
return DomainDrivenDelivery.Booking.Api.CargoRoutingDTO
        internal static CargoRoutingDTO toDTO(Cargo cargo)
        {
            var itinerary = cargo.Itinerary;

            var legDTOList = new List<LegDTO>();
            if(itinerary != null)
            {
                var legs = itinerary.Legs;

                legDTOList = new List<LegDTO>(legs.Count());
                foreach(Leg leg in legs)
                {
                    var legDTO = new LegDTO(
                      leg.Voyage.VoyageNumber.Value,
                      leg.LoadLocation.UnLocode.Value,
                      leg.UnloadLocation.UnLocode.Value,
                      leg.LoadTime,
                      leg.UnloadTime);
                    legDTOList.Add(legDTO);
                }
            }

            return new CargoRoutingDTO(
              cargo.TrackingId.Value,
              cargo.RouteSpecification.Origin.UnLocode.Value,
              cargo.RouteSpecification.Destination.UnLocode.Value,
              cargo.RouteSpecification.ArrivalDeadline,
              cargo.RoutingStatus == RoutingStatus.MISROUTED,
              legDTOList
            );
        }

Same methods

DTOAssembler::toDTO ( Location location ) : LocationDTO
DTOAssembler::toDTO ( Itinerary itinerary ) : RouteCandidateDTO

Usage Example

Ejemplo n.º 1
0
        public IEnumerable <CargoRoutingDTO> listAllCargos()
        {
            var cargoList = cargoRepository.findAll();
            var dtoList   = new List <CargoRoutingDTO>(cargoList.Count());

            foreach (Cargo cargo in cargoList)
            {
                dtoList.Add(DTOAssembler.toDTO(cargo));
            }
            return(dtoList);
        }
All Usage Examples Of DomainDrivenDelivery.Interfaces.Booking.Facade.DTOAssembler::toDTO