Beispiel #1
0
        public async Task <IHttpActionResult> PutDemande(int id, Demande demande)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != demande.IdDemande)
            {
                return(BadRequest());
            }
            db.Entry(demande).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DemandeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(demande));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> PutEtudiant(int id, Etudiant etudiant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != etudiant.IdEtudiant)
            {
                return(BadRequest());
            }

            db.Entry(etudiant).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();

                return(Ok(etudiant));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EtudiantExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PutCours(int id, Cours cours)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (id != cours.IdCours)
            {
                return(BadRequest());
            }
            db.Entry(cours).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CoursExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(cours));
        }
Beispiel #4
0
 public async Task<IActionResult> Create([Bind("Id,Prenom,nom,telephone,mail,note,departement,date_naissance")] Personne personne)
 {
     if (ModelState.IsValid)
     {
         _context.Add(personne);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(personne);
 }
        public async Task <IActionResult> Create([Bind("ID,Name,URl")] Lien lien)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lien);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lien));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,MinDuration,OurDuration,MaxDuration,MinAge,MinPlayer,BestNumberPlayer,Maxplayer,Editeur")] Game game)
        {
            if (ModelState.IsValid)
            {
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("ID,Value")] MotClef motClef)
        {
            if (ModelState.IsValid)
            {
                _context.Add(motClef);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(motClef));
        }
Beispiel #8
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Proprietaire proprietaire)
        {
            if (ModelState.IsValid)
            {
                _context.Add(proprietaire);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(proprietaire));
        }
Beispiel #9
0
        public async Task <IHttpActionResult> Post()
        {
            if (!Request.Headers.Contains("idEtudiant"))
            {
                return(BadRequest());
            }
            if (!Request.Headers.Contains("idCours"))
            {
                return(BadRequest());
            }

            Etudiant etudiant;
            Cours    cours;

            try
            {
                int idEtudiant = int.Parse(Request.Headers.GetValues("idEtudiant").FirstOrDefault());
                int idCours    = int.Parse(Request.Headers.GetValues("idCours").FirstOrDefault());

                etudiant = db.Etudiant.Find(idEtudiant);
                cours    = db.Cours.Find(idCours);

                etudiant.Cours.Add(cours);
                //				cours.Etudiants.Add(etudiant);

                db.Entry(etudiant).State = EntityState.Modified;
                //				db.Entry(cours).State = EntityState.Modified;

                await db.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(BadRequest());
            }
            return(Ok(etudiant));
        }