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)); }
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)); }
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)); }
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(); } }); }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
public void SaveRide(CRide ride) { bdd.Entry(ride).State = EntityState.Modified; bdd.SaveChanges(); }
public void Update(Client element) { _context.Entry(element).State = EntityState.Modified; }
public void Save(CDriver user) { bdd.Entry(user).State = EntityState.Modified; bdd.SaveChanges(); }