public ActionResult DeleteConfirmed(int id) { Groupe_thematiqe groupe_thematiqe = db.Groupe_thematiqe.Find(id); db.Groupe_thematiqe.Remove(groupe_thematiqe); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult UpdateStatu(int id) { Groupe_thematiqe gt = db.Groupe_thematiqe.Find(id); gt.Statut = !gt.Statut.Value; db.Groupe_thematiqe.Attach(gt); db.Entry(gt).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Groupe_thematiqe groupe_thematiqe) { if (ModelState.IsValid) { try { var currentId = User.Identity.GetUserId(); var x = db.Utilisateur.FirstOrDefault(p => p.UserId == currentId); DateTime aDate = DateTime.Now; if (groupe_thematiqe.Nom_groupe.Length <= 350) { var grpModel = new Groupe_thematiqe() { CreatedById = x.ID, Date_createion = aDate, Nom_groupe = groupe_thematiqe.Nom_groupe, Statut = false }; db.Groupe_thematiqe.Add(grpModel); db.SaveChanges(); Membre_group membre_Group = new Membre_group() { GroupId = grpModel.ID, MembreId = grpModel.CreatedById }; db.Membre_group.Add(membre_Group); db.SaveChanges(); } else { TempData["Message"] = "limite de caractère est 255 character"; return(View(groupe_thematiqe)); } } catch (DbEntityValidationException DbExc) { string error = ""; foreach (var er in DbExc.EntityValidationErrors) { foreach (var ve in er.ValidationErrors) { error += " - " + ve.ErrorMessage; } } TempData["Message"] = error; return(View(groupe_thematiqe)); } return(RedirectToAction("Index")); } return(View(groupe_thematiqe)); }
// GET: Groupe/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Groupe_thematiqe groupe_thematiqe = db.Groupe_thematiqe.Find(id); if (groupe_thematiqe == null) { return(HttpNotFound()); } return(View(groupe_thematiqe)); }
public ActionResult Edit(Groupe_thematiqe groupe_thematiqe) { if (ModelState.IsValid) { groupe_thematiqe.CreatedById = groupe_thematiqe.CreatedById; groupe_thematiqe.Date_createion = groupe_thematiqe.Date_createion; groupe_thematiqe.Statut = groupe_thematiqe.Statut; db.Entry(groupe_thematiqe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(groupe_thematiqe)); }
public ActionResult Create(Groupe_thematiqe groupe_thematiqe) { var currentId = User.Identity.GetUserId(); var x = db.Utilisateur.FirstOrDefault(p => p.UserId == currentId); DateTime aDate = DateTime.Now; var grpModel = new Groupe_thematiqe() { CreatedById = x.ID, Date_createion = aDate, Nom_groupe = groupe_thematiqe.Nom_groupe, Statut = false }; if (ModelState.IsValid) { db.Groupe_thematiqe.Add(grpModel); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(groupe_thematiqe)); }
public ActionResult Edit(Groupe_thematiqe groupe_thematiqe) { try { if (ModelState.IsValid) { if (groupe_thematiqe.Nom_groupe.Length <= 255) { groupe_thematiqe.CreatedById = groupe_thematiqe.CreatedById; groupe_thematiqe.Date_createion = groupe_thematiqe.Date_createion; groupe_thematiqe.Statut = groupe_thematiqe.Statut; db.Entry(groupe_thematiqe).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { TempData["Message"] = "limite de caractère est 255 character"; return(View(groupe_thematiqe)); } } }catch (DbEntityValidationException DbExc) { string error = ""; foreach (var er in DbExc.EntityValidationErrors) { foreach (var ve in er.ValidationErrors) { error += " - " + ve.ErrorMessage; } } TempData["Message"] = error; return(View(groupe_thematiqe)); } return(View(groupe_thematiqe)); }