public ActionResult Edit(int id, activite Activite) { try { using (SMSIEntities1 db = new SMSIEntities1()) { db.Entry(Activite).State = EntityState.Modified; db.SaveChanges(); } // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, activite Activite) { try { using (SMSIEntities1 db = new SMSIEntities1()) { Activite = db.activite.Where(x => x.id_activite == id).FirstOrDefault(); db.activite.Remove(Activite); db.SaveChanges(); } // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(activite Activite) { // TODO: Add insert logic here using (SMSIEntities1 db = new SMSIEntities1()) { activite Activites = new activite(); Activites.nom_activite = Activite.nom_activite; Activites.date_creation = DateTime.Now; Activites.matricule = Session["UserMatricule"].ToString(); var exists = db.activite.Where(w => w.id_activite == Activite.id_activite).FirstOrDefault(); if (exists != null) { //Activite.errorMessage = "Activite Deja Existant"; TempData["errorMessage"] = "Activite Deja Existant"; //ViewBag.Message = "Activite Deja Existant"; return(View("create", Activite)); } db.activite.Add(Activites); db.SaveChanges(); return(RedirectToAction("Index")); } }