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)); }
public ActionResult DeleteConfirmed(int id) { Promoteur promoteur = db.Promoteur.Find(id); db.Promoteur.Remove(promoteur); db.SaveChanges(); return(RedirectToAction("Index")); }
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)); }
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)); }
// 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)); }
// 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)); }
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)); }