コード例 #1
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                string ErrorMessage = "Id Stock matériel manquant";
                return(RedirectToAction("Index", new { MessageErreur = ErrorMessage }));
            }
            StockMateriel unStock = this.stockMaterielService.GetStockMaterielById(id);

            if (unStock == null)
            {
                return(HttpNotFound());
            }

            StockMaterielFormViewModel formModel = this.GetFormStock(true, unStock);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_AjaxEditStock", formModel));
            }
            else
            {
                return(View(formModel));
            }
        }
コード例 #2
0
        public ActionResult AjaxEdit([Bind(Include = "ID,Quantite,DatePeremption,Supprime,DateCreation,DateModification,MaterielID,TypeMaterielID")] StockMateriel unStock)
        {
            StockMaterielFormViewModel formModel = this.GetFormStock(true, unStock);

            if (ModelState.IsValid)
            {
                ActionControllerResult result = this.stockMaterielService.UpdateStockMateriel(unStock, User.Identity.GetUserId());
                if (result == ActionControllerResult.FAILURE)
                {
                    ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS;
                    return(PartialView("_FormContenuStock", formModel));
                }
                this.logService.LogEvenement(LOG_TYPE_EVENT.Edit, LOG_TYPE_OBJECT.StockMateriel, unStock.ID, "Création d'un Stock Materiel", null, User.Identity.GetUserId());
                return(Json(string.Empty));
            }
            return(PartialView("_FormContenuStock", formModel));
        }
コード例 #3
0
        public ActionResult Edit([Bind(Include = "ID,Quantite,DatePeremption,Supprime,DateCreation,DateModification,MaterielID,TypeMaterielID")] StockMateriel unStock)
        {
            StockMaterielFormViewModel formModel = this.GetFormStock(true, unStock);

            if (ModelState.IsValid)
            {
                ActionControllerResult result = this.stockMaterielService.UpdateStockMateriel(unStock, User.Identity.GetUserId());

                if (result == ActionControllerResult.FAILURE)
                {
                    ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS;
                    return(View(formModel));
                }
                return(RedirectToAction("Index"));
            }
            return(View(formModel));
        }
コード例 #4
0
        public ActionResult AjaxCreate(StockMateriel unStock)
        {
            StockMaterielFormViewModel formModel = this.GetFormStock(false, unStock);

            if (ModelState.IsValid)
            {
                ActionControllerResult result = this.stockMaterielService.InsertStockMateriel(unStock, User.Identity.GetUserId());
                if (result == ActionControllerResult.FAILURE)
                {
                    ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS;
                    return(PartialView("_FormContenuStock", formModel));
                }
                this.logService.LogEvenement(LOG_TYPE_EVENT.Create, LOG_TYPE_OBJECT.StockMateriel, null, "Création d'un Stock Materiel", null, User.Identity.GetUserId());
                return(Json(string.Empty));
            }
            return(PartialView("_FormContenuStock", formModel));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "ID,Quantite,DatePeremption,Supprime,MaterielID")] StockMateriel unStock)
        {
            StockMaterielFormViewModel formModel = this.GetFormStock(false, unStock);

            if (ModelState.IsValid)
            {
                ActionControllerResult result = this.stockMaterielService.InsertStockMateriel(unStock, User.Identity.GetUserId());
                if (result == ActionControllerResult.FAILURE)
                {
                    ViewBag.ErrorMessage = Constantes.MESSAGE_ERR_NOTIFICATIONS;
                    return(View(formModel));
                }
                this.logService.LogEvenement(LOG_TYPE_EVENT.Create, LOG_TYPE_OBJECT.StockMateriel, null, "Création d'un Stock Materiel", null, User.Identity.GetUserId());
                return(RedirectToAction("Index"));
            }
            return(View(formModel));
        }
コード例 #6
0
        public ActionResult Create()
        {
            StockMaterielFormViewModel formModel = GetFormStock(false);

            return(View("Create", formModel));
        }
コード例 #7
0
        private StockMaterielFormViewModel GetFormStock(bool isEdit, StockMateriel unStock = null, int?materielId = null)
        {
            //Gestion de la récupératio des ID
            Materiel unMateriel     = null;
            int?     IdInventaire   = null;
            int?     IdBloc         = null;
            int?     IdMateriel     = null;
            int?     IdTypeMateriel = null;

            if (unStock == null)
            {
                unStock = new StockMateriel();
            }

            if (unStock.MaterielID > 0)
            {
                unMateriel = this.materielService.GetMaterielById(unStock.MaterielID);
                IdMateriel = unStock.MaterielID;
            }
            else if (materielId != null)
            {
                unMateriel = this.materielService.GetMaterielById(materielId);
                IdMateriel = materielId;
            }

            if (IdMateriel != null)
            {
                IdInventaire       = unMateriel.BlocInventaire.InventaireID;
                IdBloc             = unMateriel.BlocInventaireID;
                unStock.MaterielID = Convert.ToInt32(IdMateriel);
                IdTypeMateriel     = unStock.TypeMaterielID;
            }


            //Création Form
            StockMaterielFormViewModel formModel = new StockMaterielFormViewModel();

            formModel.unStock = unStock;

            //Gestion des listes
            formModel.listInventaire = this.selectListHelper.AddFirstItemSelectList(new SelectList(this.inventaireService.GetInventaires(), "ID", "Nom"), IdInventaire, "Sélectionner");

            if (IdInventaire != null)
            {
                formModel.listBlocInventaire = this.selectListHelper.AddFirstItemSelectList(new SelectList(this.blocInventaireService.GetBlocsInventaireByInventaire(Convert.ToInt32(IdInventaire)), "ID", "Nom"), IdBloc, "Sélectionner");
            }
            else
            {
                formModel.listBlocInventaire = this.selectListHelper.AddFirstItemSelectList(new SelectList(Enumerable.Empty <SelectListItem>(), "ID", "Nom"), IdBloc, "Aucun");
            }

            if (IdInventaire != null)
            {
                IEnumerable <Materiel>      listMateriel   = this.materielService.GetMaterielsByBlocInventaire(Convert.ToInt32(IdBloc));
                Dictionary <string, string> dictionaryItem = new Dictionary <string, string>();

                foreach (Materiel unMat in listMateriel)
                {
                    if (unMat.TypeMateriel != null)
                    {
                        dictionaryItem.Add(unMat.ID.ToString(), unMat.TypeMateriel.Nom);
                    }
                    else
                    {
                        dictionaryItem.Add(unMat.ID.ToString(), unMat.Nom);
                    }
                }
                formModel.listMateriel = this.selectListHelper.AddFirstItemSelectList(this.selectListHelper.CreateSelectList(dictionaryItem), IdMateriel, "Sélectionner");
            }
            else
            {
                formModel.listMateriel = this.selectListHelper.AddFirstItemSelectList(new SelectList(Enumerable.Empty <SelectListItem>(), "ID", "Nom"), IdMateriel, "Aucun");
            }

            formModel.ListTypeMateriel = this.selectListHelper.AddFirstItemSelectList(new SelectList(this.typeMaterielService.GetTypeMateriels(), "ID", "Nom"), IdTypeMateriel, "Sélectionner");

            //Gestion du mode Edit et du mode Ajax
            formModel.isEdit = isEdit;
            return(formModel);
        }
コード例 #8
0
        public ActionResult GetFormCreate(int materielId)
        {
            StockMaterielFormViewModel formModel = GetFormStock(false, materielId: materielId);

            return(PartialView("_AjaxAddStock", formModel));
        }