Example #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Abscence = await _context.Abscence.FirstOrDefaultAsync(m => m.code_abs == id);

            if (Abscence == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #2
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Abscence = await _context.Abscence.FindAsync(id);

            if (Abscence != null)
            {
                _context.Abscence.Remove(Abscence);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }



            var idEtudiant = _context.Etudiant.Where(e => e.code_rfid == Rfid).FirstOrDefault().code_etudiant;


            var codeF = _context.Etudiant.Where(e => e.code_rfid == Rfid).FirstOrDefault().Filierecode_filiere;
            var codeM = _context.Matiere.Where(m => m.Filierecode_filiere == codeF).FirstOrDefault().code_matiere;
            var codeP = _context.Matiere.Where(p => p.Filierecode_filiere == codeF).FirstOrDefault().Professeurcode_professeur;
            var codeS = _context.Seance.Where(s => s.Matierecode_matiere == codeM).FirstOrDefault().code_seance;


            if (!string.IsNullOrEmpty(Rfid))

            {
                var abs = new Abscence()
                {
                    date_abs = DateTime.Now, etudiantcode_etudiant = idEtudiant, seancecode_seance = codeS, professeurcode_professeur = codeP
                };
                _context.Abscence.Add(abs);
                await _context.SaveChangesAsync();

                Message = "Checked";
            }
            else
            {
                Message = "Erreur";
            }



            return(RedirectToPage("./Index"));
        }