public async Task <IHttpActionResult> PutAbonnee(int id, Abonnee abonnee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != abonnee.Id) { return(BadRequest()); } db.Entry(abonnee).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AbonneeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> DeleteConfirmed(int id) { Abonnee abonnee = await db.Abonnees.FindAsync(id); db.Abonnees.Remove(abonnee); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,nom,prenom,adressEmail,motDePasse,confirmerMotDePasse,photo")] Abonnee abonnee) { if (ModelState.IsValid) { db.Entry(abonnee).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(abonnee)); }
public async Task <IHttpActionResult> GetAbonnee(int id) { Abonnee abonnee = await db.Abonnees.FindAsync(id); if (abonnee == null) { return(NotFound()); } return(Ok(abonnee)); }
public async Task <ActionResult> Create([Bind(Include = "Id,nom,prenom,adressEmail,motDePasse,confirmerMotDePasse,photo")] Abonnee abonnee) { if (ModelState.IsValid) { db.Abonnees.Add(abonnee); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(abonnee)); }
public async Task <IHttpActionResult> PostAbonnee(Abonnee abonnee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Abonnees.Add(abonnee); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = abonnee.Id }, abonnee)); }
// GET: AbonneesMVC/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Abonnee abonnee = await db.Abonnees.FindAsync(id); if (abonnee == null) { return(HttpNotFound()); } return(View(abonnee)); }
public async Task <IHttpActionResult> DeleteAbonnee(int id) { Abonnee abonnee = await db.Abonnees.FindAsync(id); if (abonnee == null) { return(NotFound()); } db.Abonnees.Remove(abonnee); await db.SaveChangesAsync(); return(Ok(abonnee)); }
private async void btninscrir_Clicked(object sender, EventArgs e) { Abonnee A = new Abonnee { nom = txtnom.Text, prenom = txtprenom.Text, adressEmail = txtEmail.Text, motDePasse = txtmdp.Text, confirmerMotDePasse = txtcmdp.Text }; var json = JsonConvert.SerializeObject(A); var content = new StringContent(json, Encoding.UTF8, "application/json"); var client = new HttpClient(); var response = await client.PostAsync(chemainApi, content); if (response.IsSuccessStatusCode) { await Navigation.PushModalAsync(new Accueil()); } }