Esempio n. 1
0
        public ActionResult UploadFileMilitaire()
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (!ContexteStatic.ListeExtensionUploadAutorise.Contains(StringUtils.GetExtension(file.FileName)))
                {
                    ModelState.AddModelError("fileMili", "Ce type de fichier n'est pas autorisé");
                    return(View(Db.Application.Find(1)));
                }

                using (var inputStream = file.InputStream)
                {
                    var memoryStream = inputStream as MemoryStream;
                    if (memoryStream == null)
                    {
                        memoryStream = new MemoryStream();
                        inputStream.CopyTo(memoryStream);
                    }

                    var app = Db.Application.Find(1);
                    app.FilePermMilitaire = memoryStream.ToArray();
                    Db.Entry(app).State   = EntityState.Modified;
                    Db.SaveChanges();
                    ;
                    ContexteApplication.RefreshContexteAppli();
                }
            }
            var application = Db.Application.Find(1);

            application.IsSUperAdmin = GetIdUtilisateurConnecte() == 0;
            ModelState.AddModelError("fileMili", "Fichier chargé !");
            return(View(application));
        }
Esempio n. 2
0
        public ActionResult Edit(Application application)
        {
            if (ModelState.IsValid)
            {
                //insertion des nouvelles valeurs en base
                var app = Db.Application.Find(1);
                app.AdresseMailEnvoyeur    = application.AdresseMailEnvoyeur;
                app.AdresseSmtp            = application.AdresseSmtp;
                app.EnableSsl              = application.EnableSsl;
                app.MotDePasseMailEnvoyeur = application.MotDePasseMailEnvoyeur;
                app.PortSmtp = application.PortSmtp;
                //control si super admin
                if (GetIdUtilisateurConnecte() == 0)
                {
                    app.NomUnite = application.NomUnite;
                    app.NomAppli = application.NomAppli;
                }
                Db.Entry(app).State = EntityState.Modified;
                Db.SaveChanges();
                //rechargement du contexte
                ContexteApplication.RefreshContexteAppli();
            }

            application.IsSUperAdmin = GetIdUtilisateurConnecte() == 0;
            return(View(application));
        }
Esempio n. 3
0
        protected void Application_Start()
        {
            //initialisation de la base de donnée
            Database.SetInitializer(new MySqlInitializer());

            //sécurité des pages
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

            //defaut
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            //chargement du contexte à partir de la base
            ContexteApplication.RefreshContexteAppli();
            //chargement des logs
            ContexteApplication.Log = new LogUtils();
        }