Exemple #1
0
 public IActionResult OnGet()
 {
     ViewData["JEU"]        = new SelectList(_context.Jeu, "ID", "Nom");
     licencieParticipations = new List <LicencieParticipationViewModels>();
     foreach (Licencie licencie in _context.Licensie)
     {
         if (licencie.LienceValidate)
         {
             LicencieParticipationViewModels licencieParticipation = new LicencieParticipationViewModels();
             licencieParticipation.idLiecencie = licencie.ID;
             licencieParticipation.NomLicencie = licencie.Nom;
             licencieParticipation.IsSelected  = false;
             licencieParticipations.Add(licencieParticipation);
         }
     }
     return(Page());
 }
Exemple #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            licencieParticipations = new List <LicencieParticipationViewModels>();
            Equipe = await _context.Equipe
                     .Include(u => u.jeu).FirstOrDefaultAsync(m => m.ID == id);

            if (Equipe == null)
            {
                return(NotFound());
            }

            ViewData["JEU"] = new SelectList(_context.Jeu, "ID", "Nom");

            licencies = await _context.Licensie.ToListAsync();

            foreach (Licencie licencie in licencies)
            {
                var selected = _context.MembreEquipes
                               .Where(e => e.IDEquipe.Equals(id) && e.IDLicencie.Equals(licencie.ID))
                               .FirstOrDefaultAsync();
                LicencieParticipationViewModels licencieParti = new LicencieParticipationViewModels();
                licencieParti.idLiecencie = licencie.ID;
                licencieParti.NomLicencie = licencie.Nom;
                if (selected != null)
                {
                    licencieParti.IsSelected = true;
                }
                else
                {
                    licencieParti.IsSelected = false;
                }
                licencieParticipations.Add(licencieParti);
            }

            return(Page());
        }