public ActionResult AjoutSujet([Bind(Exclude = "ID")] SUJETPUBLICATION envoiSujet) { if (String.IsNullOrWhiteSpace(envoiSujet.NOM) && String.IsNullOrWhiteSpace(envoiSujet.NOMTRAD)) { TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.ERREUR, Resources.Sujets.aucunNomSpecifie); } else if (ModelState.IsValid) { try { db.AjouterSujetPub(envoiSujet.NOM ?? "", envoiSujet.NOMTRAD ?? ""); TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.SUCCES, Resources.Sujets.sujetAjoute); return(RedirectToAction("GestionPublications")); } catch (Exception ex) { TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.ERREUR, Resources.Sujets.sujetErreur + " (" + ex.GetType() + ")"); } } return(View(envoiSujet)); }
public ActionResult ModifierSujet(int?id) { SUJETPUBLICATION suj = null; try { if (id == null) { throw new ArgumentNullException("id"); } suj = db.GetSujetPublication(id).First(); } catch { TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.ERREUR, Resources.Sujets.sujetInexistant); return(RedirectToAction("GestionSujets")); } if (suj != null) { return(View(suj)); } return(View()); }
public ActionResult SupprimerSujet(int?id, string confirmer, string annuler) { if (!String.IsNullOrEmpty(confirmer) && String.IsNullOrEmpty(annuler)) { SUJETPUBLICATION suj = null; try { if (id == null) { throw new ArgumentNullException("id"); } suj = db.GetSujetPublication(id).First(); } catch { TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.ERREUR, Resources.Sujets.idSujetInvalide); } if (suj != null) { db.SupprimerSujetPub(id); TempData[Constantes.CLE_MSG_RETOUR] = new Message(Message.TYPE_MESSAGE.SUCCES, Resources.Sujets.sujetSupprime); } } return(RedirectToAction("GestionSujets")); }