public ActionResult Create([Bind(Include = "Id,IdUsers,IdDossier,IdExercice")]  PreferencesPivot pero)
        {
            if (pero != null)
            {
                if (pero.Id > 0)
                {
                    pero.IdUsers     = Constantes.IdentifiantUser;
                    pero.IdDossier   = Constantes.IdentifiantDossier;
                    pero.IdExercices = 2;


                    preferencesServise.UpdatePreferencesPivot(pero);
                    preferencesServise.SavePreferencesPivot();
                }
                else
                {
                    pero.IdUsers     = Constantes.IdentifiantUser;
                    pero.IdDossier   = Constantes.IdentifiantDossier;
                    pero.IdExercices = 2;

                    preferencesServise.CreatePreferencesPivot(pero);
                    preferencesServise.SavePreferencesPivot();
                }


                return(RedirectToAction("Index"));
            }

            PreferencesFormViewModel per = Mapper.Map <PreferencesPivot, PreferencesFormViewModel>(pero);

            return(View(per));
        }
        public ActionResult DeleteConfirmed([Bind(Include = "Id")] PreferencesFormViewModel preferences)
        {
            PreferencesPivot preference = Mapper.Map <PreferencesFormViewModel, PreferencesPivot>(preferences);
            PreferencesPivot per        = preferencesServise.GetPreferences(preferences.Id);


            preferencesServise.DeletPreferencesPivot(per);
            // db.SaveChanges();
            preferencesServise.SavePreferencesPivot();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit([Bind(Include = "Id,IdUsers,IdDossier,IdExercice")] PreferencesPivot preferences)
        {
            if (ModelState.IsValid)
            {
                preferences.IdUsers     = Constantes.IdentifiantUser;
                preferences.IdDossier   = Constantes.IdentifiantDossier;
                preferences.IdExercices = 2;
                preferencesServise.UpdatePreferencesPivot(preferences);
                //   db.SaveChanges();
                preferencesServise.SavePreferencesPivot();
                return(RedirectToAction("Index"));
            }

            PreferencesFormViewModel Num = Mapper.Map <PreferencesPivot, PreferencesFormViewModel>(preferences);

            return(View(Num));
        }
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PreferencesPivot preferences = preferencesServise.GetPreferences((int)id);

            //db.GEN_Devises.Find(id);
            if (preferences == null)
            {
                return(HttpNotFound());
            }

            PreferencesFormViewModel preferencess = Mapper.Map <PreferencesPivot, PreferencesFormViewModel>(preferences);

            return(View(preferencess));
        }
 public ActionResult Create(long?id)
 {
     if (id == null)
     {
         //  ViewBag.IdDossier = new SelectList(GEN_Dossiers.Where(e => e.Actif), "Id", "CodeDossier");
         ViewBag.IdDossier = new SelectList(dossiersService.GetActifDossier(), "DossierId", "CodeDossier");
         return(View());
     }
     else
     {
         // GEN_Devises gEN_Devises = db.GEN_Devises.Find(id);
         var preference = preferencesServise.GetPreferences((int)id);
         if (preference == null)
         {
             TempData["errorMessage"] = "Le exercice que vous cherchez n'existe pas.";
             return(RedirectToAction("Index"));
         }
         PreferencesFormViewModel peroidFormModel = Mapper.Map <PreferencesPivot, PreferencesFormViewModel>(preference);
         return(View(peroidFormModel));
     }
 }