public ActionResult Ajout([Bind(Include = "etat,tache,detail,dateCreation,noEvenement,noSousEvenement,noUtilisateur")] tblActivite tblActivite, string UserName) { var idEvent = Request.QueryString["evenement_id"]; var idSousEvent = Request.QueryString["sousevenement_id"]; var retour = Request.QueryString["return"]; var nomResponsable = db.ReturnUtilisateur((long)Convert.ToInt32(UserName)).UserName; tblActivite.nomResponsable = nomResponsable; if (ModelState.IsValid) { if (retour.Contains("sousEvenements")) { tblActivite.noSousEvenement = Convert.ToInt32(idSousEvent); tblActivite.noEvenement = null; } else { tblActivite.noEvenement = Convert.ToInt32(idEvent); tblActivite.noSousEvenement = null; } db.InsertActivite(tblActivite); return(Redirect(retour)); } return(View(tblActivite)); }
public ActionResult Modifier([Bind(Include = "noActivite,nomResponsable,etat,dateCreation,tache,detail,dateSupprime,noEvenement,noSousEvenement,noUtilisateur")] tblActivite tblActivite, string UserName) { var retour = Request.QueryString["return"]; var nomResponsable = db.ReturnUtilisateur((long)Convert.ToInt32(UserName)).UserName; tblActivite.nomResponsable = nomResponsable; if (ModelState.IsValid) { if (db.ReturnActivite(tblActivite.noActivite).noEvenement != null) { tblActivite.noEvenement = db.ReturnActivite(tblActivite.noActivite).noEvenement; } else { tblActivite.noSousEvenement = db.ReturnActivite(tblActivite.noActivite).noSousEvenement; } db.UpdateActivite(tblActivite); return(Redirect(retour)); } ViewBag.noEvenement = new SelectList(db.ToutEvenement(), "noEvenement", "nom", tblActivite.noEvenement); ViewBag.noSousEvenement = new SelectList(db.ToutSousEvenement(), "noSousEvenement", "nom", tblActivite.noSousEvenement); return(View(tblActivite)); }
public void UpdateActivite(tblActivite tblActivite) { try { db.Entry(db.tblActivite.Find(tblActivite.noActivite)).CurrentValues.SetValues(tblActivite); db.SaveChanges(); } catch (Exception e) { LayoutController.erreur = e; } }
public void InsertActivite(tblActivite _acti) { try { db.tblActivite.Add(_acti); db.SaveChanges(); } catch (Exception e) { LayoutController.erreur = e; } }
public ActionResult Detail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblActivite activite = db.ReturnActivite((int)id); if (activite == null) { return(HttpNotFound()); } return(View(activite)); }
public ActionResult Modifier(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblActivite elementAModifier = db.ReturnActivite((int)id); if (elementAModifier == null) { return(HttpNotFound()); } ViewBag.UtilisateurCourrant = (long)AbpSession.UserId; ViewBag.Responsable = new SelectList(db.ToutUtilisateurs(), "Id", "UserName"); return(View(elementAModifier)); }