コード例 #1
0
        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));
        }
コード例 #2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Abonnee abonnee = await db.Abonnees.FindAsync(id);

            db.Abonnees.Remove(abonnee);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public async Task <IHttpActionResult> GetAbonnee(int id)
        {
            Abonnee abonnee = await db.Abonnees.FindAsync(id);

            if (abonnee == null)
            {
                return(NotFound());
            }

            return(Ok(abonnee));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        // 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));
        }
コード例 #8
0
        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());
            }
        }