Пример #1
0
 public ScheduleMappingProfile()
 {
     CreateMap <Schedule, ScheduleReadDto>()
     .ForMember(x => x.Date, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Date)));
     CreateMap <Schedule, ScheduleListViewModel>()
     .ForMember(x => x.Date, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Date)));
     CreateMap <ScheduleWriteDto, Schedule>();
 }
Пример #2
0
 public CrewMappingProfile()
 {
     CreateMap <Crew, CrewListResource>()
     .ForMember(x => x.Birthdate, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Birthdate)));
     CreateMap <Crew, CrewReadResource>()
     .ForMember(x => x.Birthdate, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Birthdate)))
     .ForMember(x => x.Ship, x => x.MapFrom(x => new { x.Ship.Id, x.Ship.Description }))
     .ForMember(x => x.Nationality, x => x.MapFrom(x => new { x.Nationality.Id, x.Nationality.Description }))
     .ForMember(x => x.Gender, x => x.MapFrom(x => new { x.Gender.Id, x.Gender.Description }));
     CreateMap <Crew, SimpleResource>()
     .ForMember(x => x.Description, x => x.MapFrom(x => x.Lastname + " " + x.Firstname + " " + DateHelpers.DateTimeToISOString(x.Birthdate)));
     CreateMap <CrewWriteResource, Crew>()
     .ForMember(x => x.Birthdate, x => x.MapFrom(x => x.Birthdate));
 }
Пример #3
0
 public ReservationMappingProfile()
 {
     // List
     CreateMap <Reservation, ReservationListResource>()
     .ForMember(x => x.Date, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Date)))
     .ForMember(x => x.CoachRouteAbbreviation, x => x.MapFrom(x => x.PickupPoint.CoachRoute.Abbreviation))
     .ForMember(x => x.DriverDescription, x => x.NullSubstitute("(EMPTY)"))
     .ForMember(x => x.ShipDescription, x => x.NullSubstitute("(EMPTY)"))
     .ForMember(x => x.Time, x => x.MapFrom(x => x.PickupPoint.Time))
     .ForMember(x => x.PassengerCount, x => x.MapFrom(x => x.Passengers.Count))
     .ForMember(x => x.PassengerDifference, x => x.MapFrom(x => x.TotalPersons - x.Passengers.Count));
     // DriverList
     CreateMap <Reservation, ReservationDriverListResource>()
     .ForMember(x => x.ExactPoint, x => x.MapFrom(x => x.PickupPoint.ExactPoint))
     .ForMember(x => x.Time, x => x.MapFrom(x => x.PickupPoint.Time))
     .ForMember(x => x.Fullname, x => x.MapFrom(x => x.Passengers.FirstOrDefault().Lastname + " " + x.Passengers.FirstOrDefault().Firstname));
     // Read reservation
     CreateMap <Reservation, ReservationReadResource>()
     .ForMember(x => x.Date, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Date)))
     .ForMember(x => x.Driver, x => x.NullSubstitute(new Driver {
         Id = 0, Description = "(EMPTY)"
     }))
     .ForMember(x => x.Ship, x => x.NullSubstitute(new Ship {
         Id = 0, Description = "(EMPTY)"
     }))
     .ForMember(x => x.PickupPoint, x => x.MapFrom(r => new PickupPointWithPortDropdownResource {
         Id          = r.PickupPoint.Id,
         Description = r.PickupPoint.Description,
         ExactPoint  = r.PickupPoint.ExactPoint,
         Time        = r.PickupPoint.Time,
         Port        = new SimpleResource {
             Id          = r.PickupPoint.CoachRoute.Port.Id,
             Description = r.PickupPoint.CoachRoute.Port.Description
         }
     }));
     // Read passenger
     CreateMap <Passenger, PassengerReadResource>()
     .ForMember(x => x.Birthdate, x => x.MapFrom(x => DateHelpers.DateTimeToISOString(x.Birthdate)));
     // Write reservation
     CreateMap <ReservationWriteResource, Reservation>();
     // Write passenger
     CreateMap <PassengerWriteResource, Passenger>();
 }
Пример #4
0
 public ManifestMappingProfile()
 {
     CreateMap <ManifestViewModel, ManifestResource>()
     .ForMember(x => x.Date, x => x.MapFrom(source => source.Date))
     .ForMember(x => x.Destination, x => x.MapFrom(source => source.Destination.Description))
     .ForMember(x => x.Port, x => x.MapFrom(source => source.Port.Description))
     .ForMember(x => x.Ship, x => x.MapFrom(source => new ManifestShipViewModel {
         Description     = source.Ship.Description,
         IMO             = source.Ship.IMO,
         Flag            = source.Ship.Flag,
         RegistryNo      = source.Ship.RegistryNo,
         Manager         = source.Ship.Manager,
         ManagerInGreece = source.Ship.ManagerInGreece,
         Agent           = source.Ship.Agent,
         ShipOwner       = new ManifestShipOwnerViewModel {
             Description = source.Ship.ShipOwner.Description,
             Profession  = source.Ship.ShipOwner.Profession,
             Address     = source.Ship.ShipOwner.Address,
             City        = source.Ship.ShipOwner.City,
             Phones      = source.Ship.ShipOwner.Phones,
             TaxNo       = source.Ship.ShipOwner.TaxNo
         },
         Registrars = source.Ship.Registrars
                      .ConvertAll(registrar => new ManifestRegistrarViewModel {
             Fullname  = registrar.Fullname,
             Phones    = registrar.Phones,
             Email     = registrar.Email,
             Fax       = registrar.Fax,
             Address   = registrar.Address,
             IsPrimary = registrar.IsPrimary
         })
                      .OrderBy(x => !x.IsPrimary)
                      .ToList(),
         Crew = source.Ship.Crews
                .ConvertAll(crew => new ManifestCrewViewModel {
             Lastname               = crew.Lastname,
             Firstname              = crew.Firstname,
             Birthdate              = DateHelpers.DateTimeToISOString(crew.Birthdate),
             GenderDescription      = crew.Gender.Description,
             NationalityDescription = crew.Nationality.Description,
             OccupantDescription    = crew.Occupant.Description,
         })
                .OrderBy(x => x.Lastname).ThenBy(x => x.Firstname)
                .ToList()
     }))
     .ForMember(x => x.ShipRoute, x => x.MapFrom(source => new ManifestShipRouteViewModel {
         Description = source.ShipRoute.Description,
         FromPort    = source.ShipRoute.FromPort,
         FromTime    = source.ShipRoute.FromTime,
         ViaPort     = source.ShipRoute.ViaPort,
         ViaTime     = source.ShipRoute.ViaTime,
         ToPort      = source.ShipRoute.ToPort,
         ToTime      = source.ShipRoute.ToTime
     }))
     .ForMember(x => x.Passengers, x => x.MapFrom(source => source.Passengers.Select(passenger => new ManifestPassengerViewModel {
         Lastname               = passenger.Lastname,
         Firstname              = passenger.Firstname,
         Birthdate              = DateHelpers.DateTimeToISOString(passenger.Birthdate),
         Remarks                = passenger.Remarks,
         SpecialCare            = passenger.SpecialCare,
         NationalityCode        = passenger.Nationality.Code,
         GenderDescription      = passenger.Gender.Description,
         NationalityDescription = passenger.Nationality.Description,
         OccupantDescription    = passenger.Occupant.Description
     }).OrderBy(x => x.Lastname).ThenBy(x => x.Firstname).ThenBy(x => x.Birthdate)));
 }