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 IEnumerable <LineModel> Get() { return(busRepository.GetAllLines().ToList().Select(x => new LineModel { Line = x.vonalId })); }