public async Task <IActionResult> Edit(int id, [Bind("CourId,name,EnseignantId,SalleId")] Cour cour)
        {
            if (id != cour.CourId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cour);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourExists(cour.CourId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnseignantId"] = new SelectList(_context.Enseignants, "EnseignantId", "cin", cour.EnseignantId);
            ViewData["SalleId"]      = new SelectList(_context.Salles, "SalleId", "SalleId", cour.SalleId);
            return(View(cour));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("SalleId,SalleTypeId,numero,nbrPlace")] Salle salle)
        {
            if (id != salle.SalleId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(salle);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalleExists(salle.SalleId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SalleTypeId"] = new SelectList(_context.Type, "SalleTypeId", "SalleTypeId", salle.SalleTypeId);
            return(View(salle));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("EnseigneId,ClasseId,EnseignantId")] Enseigne enseigne)
        {
            if (id != enseigne.EnseigneId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enseigne);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnseigneExists(enseigne.EnseigneId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClasseId"]     = new SelectList(_context.Classes, "ClasseId", "ClasseId", enseigne.ClasseId);
            ViewData["EnseignantId"] = new SelectList(_context.Enseignants, "EnseignantId", "cin", enseigne.EnseignantId);
            return(View(enseigne));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EtudiantId,Nom,Prenom,cin")] Etudiant etudiant)
        {
            if (id != etudiant.EtudiantId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(etudiant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EtudiantExists(etudiant.EtudiantId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(etudiant));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Edit(int id, [Bind("AbsenceId,Date,EtudiantId,CourId")] Absence absence)
        {
            if (id != absence.AbsenceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(absence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AbsenceExists(absence.AbsenceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourId"]     = new SelectList(_context.Cours, "CourId", "name", absence.CourId);
            ViewData["EtudiantId"] = new SelectList(_context.Etudiants, "EtudiantId", "cin", absence.EtudiantId);
            return(View(absence));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("ClasseId,niveau,nbrEtudiant")] Classe classe)
        {
            if (id != classe.ClasseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(classe);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClasseExists(classe.ClasseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(classe));
        }
        public async Task <IActionResult> Edit(int id, [Bind("SalleTypeId,name")] SalleType salleType)
        {
            if (id != salleType.SalleTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(salleType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SalleTypeExists(salleType.SalleTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(salleType));
        }
        public IActionResult Edit(EtudiantViewModel etudiantModel)
        {
            EtudiantContext etudiantContext = new EtudiantContext(connectionString);

            etudiantModel.Promotions = populatesPromotion();
            //Rajouter des contrôles dynamiques

            //if(etudiantModel.IdentifiantPromotion == 2)
            //{
            //    ModelState.AddModelError("IdentifiantPromotion", "Ne peut être égal à 2");
            //}

            IActionResult retour = null;

            if (ModelState.IsValid)
            {
                Etudiant etudiant = new Etudiant();

                etudiant.Identifiant = (int)etudiantModel.Identifiant;
                etudiant.Nom         = etudiantModel.Nom;
                etudiant.Prenom      = etudiantModel.Prenom;
                etudiant.IdPromotion = etudiantModel.IdPromotion;
                etudiant.Age         = etudiantModel.Age;
                etudiant.Genre       = etudiantModel.Genre;

                bool isOK = etudiantContext.Update(etudiant);
                retour = RedirectToAction("Index");
            }
            else
            {
                retour = View(etudiantModel);
            }

            return(retour);
        }
Ejemplo n.º 9
0
        public IActionResult Create(User user)
        {
            // TODO: Encrypt password
            _context.Update(user);
            _context.SaveChanges();

            return(new ObjectResult(user.Id));
        }
Ejemplo n.º 10
0
        public IActionResult Create(Student student)
        {
            // Save Image
            if (!string.IsNullOrEmpty(student.Photo))
            {
                string base64   = student.Photo;
                var    filePath = Path.Combine(string.Format("Uploads/Students/{0}.png", student.IndexNumber));
                _fileManager.SaveFile(filePath, base64);

                student.Photo = student.IndexNumber;
            }

            _context.Update(student);
            _context.SaveChanges();

            return(new ObjectResult(student));
        }
Ejemplo n.º 11
0
 public IActionResult Create(Branch branch)
 {
     _context.Update(branch);
     _context.SaveChanges();
     return(Ok(branch.Id));
 }
Ejemplo n.º 12
0
 public IActionResult Create(Class @class)
 {
     _context.Update(@class);
     _context.SaveChanges();
     return(Ok(@class.Id));
 }
Ejemplo n.º 13
0
 public IActionResult Create(Attendance attendance)
 {
     _context.Update(attendance);
     _context.SaveChanges();
     return(Ok(attendance.Id));
 }
Ejemplo n.º 14
0
 public IActionResult Create(StudentClass studentClass)
 {
     _context.Update(studentClass);
     _context.SaveChanges();
     return(Ok(studentClass.Id));
 }