public ActionResult BusLineDriver() { NewBusLineModel m = new NewBusLineModel(); List <Garaz> garageItems = garageRepository.GetAllBusState(); List <Vonal> lineItems = busRepository.GetAllLines(); List <Sofor> drivers = busRepository.GetAllDrivers(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Garaz, GarageModel>() .ForMember(x => x.BusId, x => x.MapFrom(y => y.buszId)); cfg.CreateMap <Vonal, LineModel>() .ForMember(x => x.Line, x => x.MapFrom(y => y.vonalId)); cfg.CreateMap <Sofor, DriverModel>() .ForMember(x => x.Id, x => x.MapFrom(y => y.soforId)) .ForMember(x => x.DriverName, x => x.MapFrom(y => y.soforNev)); }); IMapper mapper = config.CreateMapper(); m.BusesInTheGarage = mapper.Map <ICollection <Garaz>, List <GarageModel> >(garageItems); m.Lines = mapper.Map <ICollection <Vonal>, List <LineModel> >(lineItems); m.Drivers = mapper.Map <ICollection <Sofor>, List <DriverModel> >(drivers); return(View(m)); }
public ActionResult Index() { TransportModel m = new TransportModel(); List <Garaz> garageItems = garageRepository.GetAllBusState(); List <Megallok> busStationItems = busStationRepository.GetAllStation(); List <Uzenet> messageItems = messageRepository.GetAllMessage(); List <VonalMegallok> lineStationsItems = messageRepository.GetAllLineStation(); List <Felszalla> busesOnTheRoad = messageRepository.GetAllBusOnRoad(); var config = new MapperConfiguration(cfg => { cfg.CreateMap <Megallok, StationModel>() .ForMember(x => x.Id, x => x.MapFrom(y => y.megalloId)) .ForMember(x => x.Name, x => x.MapFrom(y => y.megalloNev)) .ForMember(x => x.lat, x => x.MapFrom(y => y.lat)) .ForMember(x => x.lon, x => x.MapFrom(y => y.lon)); cfg.CreateMap <Garaz, GarageModel>() //.ForMember(x => x.GarageId, x => x.MapFrom(y => y.garazsid)) .ForMember(x => x.BusId, x => x.MapFrom(y => y.buszId)); cfg.CreateMap <Uzenet, MessageModel>() .ForMember(x => x.MessageId, x => x.MapFrom(y => y.uzenetId)) .ForMember(x => x.DriverName, x => x.MapFrom(y => y.Sofor.soforNev)) .ForMember(x => x.MessageTypeName, x => x.MapFrom(y => y.Jelze.jelzesNev)) .ForMember(x => x.Line, x => x.MapFrom(y => y.Vonal.vonalId)) .ForMember(x => x.Bus, x => x.MapFrom(y => y.Busz.buszId)) .ForMember(x => x.MessageDate, x => x.MapFrom(y => y.datum)) .ForMember(x => x.MessageLat, x => x.MapFrom(y => y.lon)) .ForMember(x => x.MessageLon, x => x.MapFrom(y => y.lat)); cfg.CreateMap <VonalMegallok, LineStationModel>() .ForMember(x => x.Id, x => x.MapFrom(y => y.vonalMegalloiId)) .ForMember(x => x.lineId, x => x.MapFrom(y => y.vonalId)) .ForMember(x => x.stationId, x => x.MapFrom(y => y.megalloId)) .ForMember(x => x.lat, x => x.MapFrom(y => y.Megallok.lat)) .ForMember(x => x.lon, x => x.MapFrom(y => y.Megallok.lon)) .ForMember(x => x.stationName, x => x.MapFrom(y => y.Megallok.megalloNev)); cfg.CreateMap <Felszalla, BusesOnTheRoadModel>() .ForMember(x => x.Id, x => x.MapFrom(y => y.felszallasId)) .ForMember(x => x.Line, x => x.MapFrom(y => y.vonalId)) .ForMember(x => x.lat, x => x.MapFrom(y => y.lat)) .ForMember(x => x.lon, x => x.MapFrom(y => y.lon)) .ForMember(x => x.Date, x => x.MapFrom(y => y.datum)); }); IMapper mapper = config.CreateMapper(); m.BusesInTheGarage = mapper.Map <ICollection <Garaz>, List <GarageModel> >(garageItems); m.Stations = mapper.Map <ICollection <Megallok>, List <StationModel> >(busStationItems); m.Messages = mapper.Map <ICollection <Uzenet>, List <MessageModel> >(messageItems); m.LineStations = mapper.Map <ICollection <VonalMegallok>, List <LineStationModel> >(lineStationsItems); m.BusesOnTheRoad = mapper.Map <ICollection <Felszalla>, List <BusesOnTheRoadModel> >(busesOnTheRoad); return(View(m)); }