コード例 #1
0
        public async Task <ActionResult <Promoteur> > Put(int id, [FromBody] Promoteur promoteur)
        {
            var findPromoteur = await _context.Promoteurs.FindAsync(id);

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

            var promoteurExist = from p in _context.Promoteurs
                                 where p.Id != id && (p.Contact == promoteur.Contact || p.Mail == promoteur.Mail)
                                 select new { p.Id, p.Nom, p.Contact, p.Mail, p.Photo };

            if (promoteurExist.Count() > 0)
            {
                return(Conflict("Les informations existent déja !"));
            }

            findPromoteur.Nom      = promoteur.Nom;
            findPromoteur.Mail     = promoteur.Mail;
            findPromoteur.Contact  = promoteur.Contact;
            findPromoteur.UpdateAt = DateTime.Now;

            await _context.SaveChangesAsync();

            return(Ok(findPromoteur));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Promoteur promoteur = db.Promoteur.Find(id);

            db.Promoteur.Remove(promoteur);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "idPromoteur,xid,admin")] Promoteur promoteur)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promoteur).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.xid = new SelectList(db.Account, "id", "Nom", promoteur.xid);
     return(View(promoteur));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "idPromoteur,xid,admin")] Promoteur promoteur)
        {
            if (ModelState.IsValid)
            {
                db.Promoteur.Add(promoteur);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.xid = new SelectList(db.Account, "id", "Nom", promoteur.xid);
            return(View(promoteur));
        }
コード例 #5
0
        // GET: Promoteurs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Promoteur promoteur = db.Promoteur.Find(id);

            if (promoteur == null)
            {
                return(HttpNotFound());
            }
            return(View(promoteur));
        }
コード例 #6
0
        // GET: Promoteurs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Promoteur promoteur = db.Promoteur.Find(id);

            if (promoteur == null)
            {
                return(HttpNotFound());
            }
            ViewBag.xid = new SelectList(db.Account, "id", "Nom", promoteur.xid);
            return(View(promoteur));
        }
コード例 #7
0
        public async Task <ActionResult <Promoteur> > Post([FromBody] Promoteur promoteur)
        {
            var promoteurExist = from p in _context.Promoteurs
                                 where p.Contact == promoteur.Contact || p.Mail == promoteur.Mail
                                 select new { p.Id, p.Nom, p.Contact, p.Mail, p.Photo };

            if (promoteurExist.Count() > 0)
            {
                return(Conflict("Les informations existent déja !"));
            }

            await _context.Promoteurs.AddAsync(promoteur);

            await _context.SaveChangesAsync();

            return(Ok(promoteur));
        }