public ActionControllerResult ChangeOrdreBlocInventaire(int Id, int newOrdre, string userId = null) { ActionControllerResult result; try { BlocInventaire unBlocInventaire = this.blocInventaireRepository.GetByID(Id); if (unBlocInventaire == null) { return(ActionControllerResult.FAILURE); } unBlocInventaire.DateModification = DateTime.Now; unBlocInventaire.Rank = newOrdre; this.blocInventaireRepository.Update(unBlocInventaire); this.unitOfWork.Save(); result = ActionControllerResult.SUCCESS; } catch (Exception ex) { this.logService.LogErreur(LOG_TYPE_OBJECT.BlocInventaire, null, "Erreur Lors de la modification de l'ordre d'un bloc inventaire", ex.Message, userId); result = ActionControllerResult.FAILURE; } return(result); }
public ActionResult Details(int?id, bool?isFromInventaire) { if (id == null) { string ErrorMessage = "Id Bloc Inventaire manquant"; return(RedirectToAction("Index", new { MessageErreur = ErrorMessage })); } BlocInventaire unBlocInventaire = this.blocInventaireService.GetBlocInventaireById(id); if (unBlocInventaire == null) { return(HttpNotFound()); } //Gestion session isFromInventaire if (isFromInventaire != null && isFromInventaire == true) { if (Session["isFromInventaire"] == null) { Session.Add("isFromInventaire", true); } } //Gestion Session isFromBlocInventaire if (Session["isFromBlocInventaire"] != null) { Session.Remove("isFromBlocInventaire"); } this.IsFromInventaire(); return(View(unBlocInventaire)); }
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 Delete(int?id) { if (id == null) { string ErrorMessage = "Id Bloc Inventaire manquant"; return(RedirectToAction("Index", new { MessageErreur = ErrorMessage })); } BlocInventaire unBlocInventaire = this.blocInventaireService.GetBlocInventaireById(id); if (unBlocInventaire == null) { return(HttpNotFound()); } return(View(unBlocInventaire)); }
public ActionControllerResult UpdateBlocInventaire(BlocInventaire unBlocInventaire, string userId = null) { ActionControllerResult result; try { unBlocInventaire.DateModification = DateTime.Now; this.blocInventaireRepository.Update(unBlocInventaire); this.unitOfWork.Save(); result = ActionControllerResult.SUCCESS; } catch (Exception ex) { this.logService.LogErreur(LOG_TYPE_OBJECT.BlocInventaire, null, "Erreur Lors de la modification d'un bloc inventaire", ex.Message, userId); result = ActionControllerResult.FAILURE; } return(result); }
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); }