public async Task <ActionResult> Edit([Bind(Include = "Id,idParcours,Libelle,NoteActuelle,DateDerniereEval,Logo,infos")] ModuleMVC moduleMVC)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <ModuleMVC, Module>());
            var mapper = new Mapper(config);

            Module module = new Module();

            module = mapper.Map <Module>(moduleMVC);
            if (ModelState.IsValid)
            {
                db.Entry(module).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.idParcours = new SelectList(db.Parcours, "Id", "Nom", module.idParcours);
            return(View(moduleMVC));
        }
        // GET: Modules/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Module module = await db.Module.FindAsync(id);

            if (module == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idParcours = new SelectList(db.Parcours, "Id", "Nom", module.idParcours);
            ModuleMVC moduleMVC = new ModuleMVC();
            var       config    = new MapperConfiguration(x => x.CreateMap <Module, ModuleMVC>());
            var       mapper    = new Mapper(config);

            moduleMVC = mapper.Map <ModuleMVC>(module);
            return(View(moduleMVC));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,idParcours,Libelle,NoteActuelle,DateDerniereEval,Logo,infos")] ModuleMVC moduleMVC)
        {
            Module module = new Module();

            //Créer une configuration de Mapper --cas de Mappage avec classe source et dest
            var config = new MapperConfiguration(cfg => cfg.CreateMap <ModuleMVC, Module>());

            //Créer un Mapper en lui passant en param la config crée
            var mapper = new Mapper(config);

            // faire  l'affectation

            module = mapper.Map <Module>(moduleMVC);
            if (ModelState.IsValid)
            {
                db.Module.Add(module);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.idParcours = new SelectList(db.Parcours, "Id", "Nom", module.idParcours);
            return(View(moduleMVC));
        }