Exemplo n.º 1
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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
 private async void downloadDone(Task <List <Models.Calendrier> > result)
 {
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         List <Models.Calendrier> matchs = result.Result;
         using (BddContext bddContext = new BddContext())
         {
             foreach (Models.Calendrier match in matchs)
             {
                 if (bddContext.Calendriers.Any(item => match.Equipe1 == item.Equipe1 &&
                                                match.Equipe2 == item.Equipe2 &&
                                                match.Categorie == item.Categorie))
                 {
                     Models.Calendrier matchBdd = bddContext.Calendriers.First(item => match.Equipe1 == item.Equipe1 &&
                                                                               match.Equipe2 == item.Equipe2 &&
                                                                               match.Categorie == item.Categorie);
                     matchBdd.Date   = match.Date;
                     matchBdd.Score1 = match.Score1;
                     matchBdd.Score2 = match.Score2;
                     bddContext.Entry(matchBdd).State = Microsoft.Data.Entity.EntityState.Modified;
                 }
                 else
                 {
                     bddContext.Calendriers.Add(match);
                 }
                 matchsObservable.Add(match);
             }
             bddContext.SaveChanges();
         }
     });
 }
Exemplo n.º 5
0
        public static async Task <List <Actu> > updateActus()
        {
            List <Actu> actus = await DataDownloader.download <Actu>(ServerConstants.ACTUS_URL, null);

            using (var bddContext = new BddContext())
            {
                foreach (Actu actu in actus)
                {
                    if (bddContext.Actus.Any(item => actu.PostId == item.PostId))
                    {
                        Actu actuBdd = bddContext.Actus.First(item => actu.PostId == item.PostId);
                        actuBdd.Texte    = actu.Texte;
                        actuBdd.Titre    = actu.Titre;
                        actuBdd.URL      = actu.URL;
                        actuBdd.ImageURL = actu.ImageURL;
                        bddContext.Entry(actuBdd).State = Microsoft.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        bddContext.Actus.Add(actu);
                    }
                }
                bddContext.SaveChanges();
            }
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            localSettings.Values[typeof(Actu).Name + "SyncDate"] = DateTime.Now.ToString();
            return(actus);
        }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "Id,AttaqueInf,DefenseInf,PvMaxInf,AttaqueArcher,DefenseArcher,PvMaxArcher,AttaqueCava,DefenseCava,PvMaxCava,AttaqueArmee,DefenseArmee,PvMaxArmee")] StatsMixte statsMixte)
 {
     if (ModelState.IsValid)
     {
         db.Entry(statsMixte).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(statsMixte));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Id,NomBatiment,Niveau")] Batiment batiment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(batiment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(batiment));
 }
Exemplo n.º 8
0
 public ActionResult Edit([Bind(Include = "Id,Nom,Production,Stock")] Ressource ressource)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ressource).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ressource));
 }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,Nom,Niveau,Rang,Couleur,Medailles")] Hero hero)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hero).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hero));
 }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "Id,Nom")] Chateau chateau)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chateau).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(chateau));
 }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "Id,Date,InfanterieT1,ArcherT1,CavalerieT1,EnginSiegeT1,InfanterieT2,ArcherT2,CavalerieT2,EnginSiegeT2,InfanterieT3,ArcherT3,CavalerieT3,EnginSiegeT3,InfanterieT4,ArcherT4,CavalerieT4,EnginSiege")] Troupes troupes)
 {
     if (ModelState.IsValid)
     {
         db.Entry(troupes).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(troupes));
 }
Exemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "Id,NomFormation,AttaqueFormation,DefenseFormation,PvMaxFormation,AttaqueArmee,DefenseArmee,PvMaxArmee")] StatsMono statsMono)
 {
     if (ModelState.IsValid)
     {
         db.Entry(statsMono).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(statsMono));
 }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Id,Nom,Niveau,Categorie")] Recherche recherche)
 {
     if (ModelState.IsValid)
     {
         db.Entry(recherche).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(recherche));
 }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "IDClient,Nom,Prenom,GSM,Email")] Client client)
 {
     if (ModelState.IsValid)
     {
         db.Entry(client).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(client));
 }
Exemplo n.º 15
0
 public ActionResult Edit([Bind(Include = "IDFournisseur,Nom_Fournisseur,GSM,Adresse_Email,Adresse,Code_Postal")] Fournisseur fournisseur)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fournisseur).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fournisseur));
 }
Exemplo n.º 16
0
        public ActionResult Edit([Bind(Include = "IDVelo,Marque,Pouces,Annee_achat,Couleur,Prix_location,Prix_vente,Caution,NomImage")] Velo velo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(velo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(velo));
        }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "IDAchat,Date_Achat,Prix,IDVelo,IDFournisseur")] Achat achat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(achat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDFournisseur = new SelectList(db.Fournisseur, "IDFournisseur", "Nom_Fournisseur", achat.IDFournisseur);
     ViewBag.IDVelo        = new SelectList(db.Velo, "IDVelo", "Marque", achat.IDVelo);
     return(View(achat));
 }
Exemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "IDVente,Date_vente,Prix_vente,IDClient,IDVelo")] Vente vente)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vente).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDClient = new SelectList(db.Client, "IDClient", "Nom", vente.IDClient);
     ViewBag.IDVelo   = new SelectList(db.Velo, "IDVelo", "Marque", vente.IDVelo);
     return(View(vente));
 }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "IDLocation,Date_Debut,Date_Fin,Prix_location,Caution,IDClient,IDVelo")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IDClient = new SelectList(db.Client, "IDClient", "Nom", location.IDClient);
     ViewBag.IDVelo   = new SelectList(db.Velo, "IDVelo", "Marque", location.IDVelo);
     return(View(location));
 }
Exemplo n.º 20
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));
        }
Exemplo n.º 21
0
 public void SaveRide(CRide ride)
 {
     bdd.Entry(ride).State = EntityState.Modified;
     bdd.SaveChanges();
 }
Exemplo n.º 22
0
 public void Update(Client element)
 {
     _context.Entry(element).State = EntityState.Modified;
 }
Exemplo n.º 23
0
 public void Save(CDriver user)
 {
     bdd.Entry(user).State = EntityState.Modified;
     bdd.SaveChanges();
 }