public ActionResult Edit(int?id) { if (id == null && !Request.IsAjaxRequest()) { string ErrorMessage = "Id Bloc-Inventaire manquant"; return(RedirectToAction("Index", new { MessageErreur = ErrorMessage })); } BlocInventaire unBlocInventaire = this.blocInventaireService.GetBlocInventaireById(id); if (unBlocInventaire == null && !Request.IsAjaxRequest()) { return(HttpNotFound()); } this.IsFromInventaire(); FormBlocInventaireViewModels formModel = this.GetFormBlocInventaire(true, unBlocInventaire); if (Request.IsAjaxRequest()) { return(PartialView("_AjaxEditBlocInventaire", formModel)); } else { return(View(formModel)); } }
public ActionResult AjaxCreate(BlocInventaire unBlocInventaire) { FormBlocInventaireViewModels formModel = this.GetFormBlocInventaire(false, unBlocInventaire); if (ModelState.IsValid) { ActionControllerResult result = this.blocInventaireService.InsertBlocInventaire(unBlocInventaire, User.Identity.GetUserId()); if (result == ActionControllerResult.FAILURE) { ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS; return(PartialView("_FormContenuBlocInventaire", formModel)); } //Réussi this.logService.LogEvenement(LOG_TYPE_EVENT.Create, LOG_TYPE_OBJECT.BlocInventaire, unBlocInventaire.ID, "Création d'un bloc Inventaire", null, User.Identity.GetUserId()); return(Json(string.Empty)); } return(PartialView("_FormContenuBlocInventaire", formModel)); }
public ActionResult AjaxEdit([Bind(Include = "ID,Nom,Rank,Active,DateCreation,DateModification,InventaireID")] BlocInventaire unBlocInventaire) { FormBlocInventaireViewModels formModel = this.GetFormBlocInventaire(false, unBlocInventaire); if (ModelState.IsValid) { ActionControllerResult result = this.blocInventaireService.UpdateBlocInventaire(unBlocInventaire, User.Identity.GetUserId()); if (result == ActionControllerResult.FAILURE) { ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS; return(PartialView("_FormContenuBlocInventaire", formModel)); } //Réussi this.logService.LogEvenement(LOG_TYPE_EVENT.Edit, LOG_TYPE_OBJECT.BlocInventaire, unBlocInventaire.ID, "Modification d'un bloc Inventaire", null, User.Identity.GetUserId()); return(Json(string.Empty)); } return(PartialView("_FormContenuBlocInventaire", formModel)); }
public ActionResult Create(BlocInventaire unBlocInventaire) { FormBlocInventaireViewModels formModel = this.GetFormBlocInventaire(false, unBlocInventaire); if (ModelState.IsValid) { //insertion du blocInventaire ActionControllerResult result = this.blocInventaireService.InsertBlocInventaire(unBlocInventaire, User.Identity.GetUserId()); //si erreur on affiche un message if (result == ActionControllerResult.FAILURE) { ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS; return(View(formModel)); } //Réussi this.logService.LogEvenement(LOG_TYPE_EVENT.Create, LOG_TYPE_OBJECT.BlocInventaire, unBlocInventaire.ID, "Création d'un bloc Inventaire", null, User.Identity.GetUserId()); return(RedirectToAction("Index")); } return(View(formModel)); }
public ActionResult Edit([Bind(Include = "ID,Nom,Rank,Active,DateCreation,DateModification,InventaireID")] BlocInventaire unBlocInventaire) { FormBlocInventaireViewModels formModel = this.GetFormBlocInventaire(true, unBlocInventaire); if (ModelState.IsValid) { ActionControllerResult result = this.blocInventaireService.UpdateBlocInventaire(unBlocInventaire, User.Identity.GetUserId()); if (result == ActionControllerResult.FAILURE) { ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS; this.IsFromInventaire(); return(View(formModel)); } //Réussi this.logService.LogEvenement(LOG_TYPE_EVENT.Edit, LOG_TYPE_OBJECT.BlocInventaire, unBlocInventaire.ID, "Modification d'un bloc Inventaire", null, User.Identity.GetUserId()); if (Session["isFromInventaire"] != null) { if (Convert.ToBoolean(Session["isFromInventaire"])) { return(RedirectToAction("Details", "BlocInventaire", new { id = unBlocInventaire.ID, isFromInventaire = true })); } else { return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } } this.IsFromInventaire(); return(View(formModel)); }
private FormBlocInventaireViewModels GetFormBlocInventaire(bool isEdit, BlocInventaire unBlocInventaire = null, int?inventaireId = null) { int?IdInventaire = null; if (unBlocInventaire != null) { IdInventaire = unBlocInventaire.InventaireID; } else if (inventaireId != null) { IdInventaire = inventaireId; } if (unBlocInventaire == null) { unBlocInventaire = new BlocInventaire(); unBlocInventaire.Active = true; unBlocInventaire.Rank = 1; if (IdInventaire != null) { unBlocInventaire.InventaireID = Convert.ToInt32(IdInventaire); } } FormBlocInventaireViewModels formModel = new FormBlocInventaireViewModels(); formModel.unBlocInventaire = unBlocInventaire; //Gestion des listes formModel.listInventaire = new SelectList(this.inventaireService.GetInventaires(), "Id", "Nom", IdInventaire); //Gestion du mode Edit et du mode Ajax formModel.isEdit = isEdit; return(formModel); }
public ActionResult Create() { FormBlocInventaireViewModels formModel = GetFormBlocInventaire(false); return(View("Create", formModel)); }
public ActionResult GetFormCreate(int?inventaireId = null) { FormBlocInventaireViewModels formModel = GetFormBlocInventaire(false, inventaireId: inventaireId); return(PartialView("_AjaxAddBlocInventaire", formModel)); }