// GET: ListeDeVoyages/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var listeDetails = new ListeVoyageViewModel(); listeDetails.ListeDeVoyage = await _context.ListesDeVoyage .FirstOrDefaultAsync(m => m.IdListe == id); if (listeDetails.ListeDeVoyage == null) { return(NotFound()); } var batiments = from liste in _context.ListesDeVoyage join batlist in _context.BatimentsListesDeVoyage on liste.IdListe equals batlist.IdListe join batiment in _context.Batiments on batlist.BatimentId equals batiment.BatimentId where liste.IdListe == id select new Batiment { BatimentId = batiment.BatimentId, NomBatiment = batiment.NomBatiment, Adresse = batiment.Adresse, URLPhoto = batiment.URLPhoto, }; listeDetails.Batiments = batiments.ToList(); return(View(listeDetails)); }
public async Task <IActionResult> AddBatiment(int id) { var listeDetails = new ListeVoyageViewModel(); var batiments = from batiment in _context.Batiments //join ville in _context.Batiments on batiment.VilleId equals ville.VilleId join batlist in _context.BatimentsListesDeVoyage on batiment.BatimentId equals batlist.BatimentId into gj from subbat in gj.DefaultIfEmpty() where subbat.IdListe != id select new Batiment { BatimentId = batiment.BatimentId, NomBatiment = batiment.NomBatiment, Adresse = batiment.Adresse, URLPhoto = batiment.URLPhoto, //Ville = ville.Ville }; listeDetails.Batiments = batiments.ToList(); listeDetails.ListeDeVoyage = await _context.ListesDeVoyage .FirstOrDefaultAsync(m => m.IdListe == id); if (listeDetails.ListeDeVoyage == null) { return(NotFound()); } return(View(listeDetails)); }