public ActionResult Configuration(UserSAConfigurationModel objUC)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var languageData = Upsilab.Business.Utility.PageLanguageHelper.GetLanguageContent("Public", "Configuration");

                    // Tester si l'email est deja existant
                    User user = UserBL.GetUserByEmail(objUC.Email);

                    if (user == null) //Si non existant
                    {
                        UserProfile objUserProfile = UserProfileBL.GetUserProfileByProfileName(UserProfileBL.Administrator);

                        if (objUserProfile != null)
                        {

                            if (!UserBL.IsEmailUsed(objUC.Email))
                            {
                                #region "Enregistrement de l'USER"
                                Upsilab.Data.Model.User objUser = new Upsilab.Data.Model.User()
                                {
                                    idUser = Guid.NewGuid(),
                                    idUserProfile = objUserProfile.idUserProfile,
                                    UserLogin = objUC.Email,
                                    UserPassword = string.Empty, //objUC.Password
                                    UserEmail = objUC.Email,
                                    UserName = objUC.UserName,
                                    UserFirstName = objUC.UserFirstName,
                                    UserMobilePhone = objUC.UserMobilePhone,
                                    DateCreated = DateTime.Now,
                                    IsActive = true
                                };

                                UserBL.CreateUser(objUser, objUser.UserPassword);
                                #endregion

                                FirmInstitution firmInstitution = FirmInstitutionBL.GetFirmInstitutionByIdFirmInstitution(objUC.IdFirmInstitution);

                                #region Création de l'adviser correspondant à l'admin

                                FirmInstitutionAdviser _adv = new FirmInstitutionAdviser()
                                {
                                    idUser = objUser.idUser,
                                    idFirmInstitution = firmInstitution.idFirmInstitution,
                                    idFirmInstitutionParent = firmInstitution.idFirmInstitution,
                                    DateCreated = DateTime.Now,
                                };

                                Business.Configuration.FirmInstitutionAdviserBL.CreateAdminAdviser(_adv, objUser);

                                #endregion

                                if (firmInstitution != null)
                                {
                                    #region "Mise à jour de la FirmInstitution (ajout de IdUserCreated)"
                                    firmInstitution.idUserCreated = objUser.idUser;

                                    using (UpsilabEntities context = new UpsilabEntities())
                                    {
                                        context.FirmInstitution.Attach(firmInstitution);
                                        context.ObjectStateManager.ChangeObjectState(firmInstitution, System.Data.EntityState.Modified);
                                        context.SaveChanges();
                                    }

                                    SessionManager.SetSelectedFirmInstitutionBySuperAdmin(firmInstitution);

                                    #endregion

                                    Subscription currentSubscription = SouscriptionBL.GetSubscriptionsById(objUC.IdSubscription);

                                    #region "Envoi de mail"
                                    if (currentSubscription.IsPaid)
                                    {
                                        //Send mail
                                        try
                                        {
                                            //Ne plus envoyer d'email au contact facturation
                                            //bool sendToFirmInstituion = true;
                                            //SouscriptionBL.SendInvoiceMail(currentSubscription, sendToFirmInstituion); //Send to contact facturation (not to admin)

                                            ///Envoi mail de réinitalisation de mot de passe et de confirmation commande à l'admin
                                            ///+ set date envoi email
                                            //string returnMessage;
                                            //UserBL.SendResetPasswordEmail(objUser, out returnMessage);
                                            SouscriptionBL.SendAccessActivationEmail(currentSubscription);
                                        }
                                        catch (Exception ex)
                                        {
                                            Upsilab.Business.Log.Log.AppendException(ex);
                                        }

                                        //Set date send mail
                                        currentSubscription.DateSendEmail = DateTime.Now;
                                        SouscriptionBL.UpdateSubscription(currentSubscription);
                                    }
                                    #endregion
                                }

                                ViewBag.Info = languageData.GetContent("Config_Saved");

                                //Souscription OK : TODO
                                IDictionary<string, string> dicoRes = new Dictionary<string, string>();

                                dicoRes.Add("Page_title", LanguageData.GetContent("Page_title"));
                                dicoRes.Add("Title_h1", LanguageData.GetContent("Title_h1"));
                                dicoRes.Add("Title_h1_span", LanguageData.GetContent("Title_h1_span"));
                                dicoRes.Add("Table_Title", LanguageData.GetContent("Table_Title_ok"));
                                dicoRes.Add("Message", LanguageData.GetContent("Message_ok"));
                                dicoRes.Add("ProductType", SouscriptionBL.Product_Type_Recueil_lab);

                                TempData["DicoRetour"] = dicoRes;
                                return RedirectToAction("Retour");

                            }

                            else
                            {
                                ViewBag.Info = string.Format("{0}<br/>", languageData.GetContent("mot_de_passe_obligatoirement"));
                                ViewBag.Info += string.Format("- {0}<br/>", languageData.GetContent("mot_de_passe_longueur_minimale"));
                                ViewBag.Info += string.Format("- {0}<br/>", languageData.GetContent("mot_de_passe_uniquement_chiffre_et_lettres"));
                                ViewBag.Info += string.Format("- {0}<br/>", languageData.GetContent("mot_de_passe_au_moins_2_chiffre"));
                                ViewBag.Info += string.Format("{0}<br/>", languageData.GetContent("mot_de_passe_sensible_a_la_casse"));
                            }
                        } // Fin test profil
                        else
                        {
                            ViewBag.Info = languageData.GetContent("Config_ProfilError");
                        }
                    } //Fin test email existant
                    else
                    {
                        ViewBag.Info = languageData.GetContent("Config_UsedMail"); ;
                    }
                }

            }
            catch (Exception ex)
            {
                ViewBag.Info = "Erreur: " + ex.Message;
            }

            return View("UnLogiciel_Configuration", objUC);
        }
        public ActionResult Configuration(int id = 0)
        {
            Subscription subscription = Upsilab.Business.Souscription.SouscriptionBL.GetSubscriptionsById(id);
            List<User> superAdminUsers = UserBL.GetSuperAdmins();
            List<Guid> superAdminIds = superAdminUsers.Select(u => u.idUser).ToList();

            // Si souscription faite par un superAdmin
            if (subscription != null && superAdminIds.Contains(subscription.FirmInstitution.idUserCreated.Value))
            {
                UserSAConfigurationModel objUCM = new UserSAConfigurationModel()
                {
                    IdFirmInstitution = subscription.IdFirmInstitution,
                    IdSubscription = subscription.IdSubscription,
                };

                FirmInstitution contactFacturationInSession = SessionManager.GetSelectedFirmInstitutionBySuperAdmin();
                objUCM.Email = contactFacturationInSession.E_mail;
                objUCM.UserName = contactFacturationInSession.ContactName;
                objUCM.UserFirstName = contactFacturationInSession.ContactFirstName;

                return View("UnLogiciel_Configuration", objUCM);
            }
            else
            {
                var languageDataSA = Upsilab.Business.Utility.PageLanguageHelper.GetLanguageContent("User", "SuperAdminSoucrireLogiciel");
                ViewBag.ShowInfo = languageDataSA.GetContent("sa_admin_already_defined");
                return View("UnLogiciel_Configuration");
            }
        }