Example #1
0
        public ActionResult EditTemplate(Guid?hash)
        {
            Templates         val        = new Templates();
            TEMPLATEViewModel templateVm = val.GetDetailsTemplate(hash);

            return(View(templateVm));
        }
Example #2
0
        public ActionResult CreateProjet(TEMPLATEViewModel model)
        {
            PROJET projet = new PROJET {
                projetId = Guid.NewGuid(), projet_name = model.PROJET.projet_name
            };

            db.PROJETS.Add(projet);
            db.SaveChanges();

            TEMPLATEViewModel templateVm = SetTemplateVM();

            return(View("CreateTemplate", templateVm));
        }
Example #3
0
        private TEMPLATEViewModel SetTemplateVM()
        {
            Templates         val        = new Templates();
            TEMPLATEViewModel templateVm = new TEMPLATEViewModel();

            templateVm.ListProjet = val.GetListProjetItem();
            templateVm.ListTheme  = val.GetListThemeItem();
            var             modeleId = Session["modeleId"];
            MODELEViewModel modelVm  = new MODELEViewModel();

            modelVm        = new Modeles().GetDetailsModele(Guid.Parse(modeleId.ToString()));
            templateVm.url = modelVm.site_url;
            return(templateVm);
        }
Example #4
0
        public ActionResult CreateTemplate(Guid?hash)
        {
            Templates         val        = new Templates();
            TEMPLATEViewModel templateVm = SetTemplateVM();

            //templateVm.ListProjet = val.GetListProjetItem();
            //templateVm.ListTheme = val.GetListThemeItem();
            //var modeleId = Session["modeleId"];
            //MODELEViewModel modelVm = new MODELEViewModel();
            //modelVm = new Modeles().GetDetailsModele(Guid.Parse(modeleId.ToString()));
            //templateVm.url = modelVm.site_url;

            return(View(templateVm));
        }
Example #5
0
        public ActionResult SaveEditTemplate(Guid idTemplate, TEMPLATEViewModel model, FormCollection collection)
        {
            var      hash     = idTemplate;
            TEMPLATE template = db.TEMPLATEs.Find(hash);

            template.MODELE.site_url = model.MODELE.site_url;
            template.url             = model.url;
            template.ftpUser         = model.ftpUser;
            template.ftpPassword     = model.ftpPassword;
            template.ip = model.ip;

            int result = db.SaveChanges();

            if (result > 0)
            {
                return(View("EditTemplateConfirmation"));
            }
            else
            {
                return(View("ErrorException"));
            }
        }
Example #6
0
        public ActionResult SaveTemplate(TEMPLATEViewModel model, FormCollection collection)
        {
            int res = 0;

            var    selectedProjetId = model.listprojetId;
            var    selectedThemeId  = model.listThemeId;
            string ftpdir           = "";

            if (!string.IsNullOrEmpty(collection["ftpdirs"]))
            {
                ftpdir = collection["ftpdirs"];
            }

            if (!string.IsNullOrEmpty(Request.QueryString["currentid"]))
            {
                _userId = Guid.Parse(Request.QueryString["currentid"]);
                Session["currentid"] = Request.QueryString["currentid"];
            }
            else if (!string.IsNullOrEmpty(HttpContext.User.Identity.Name))
            {
                _userId = Guid.Parse(HttpContext.User.Identity.Name);
            }

            MODELEViewModel modelVm = new MODELEViewModel();

            modelVm         = new Modeles().GetDetailsModele((Guid)Session["modeleId"]);
            Session["Menu"] = "1";
            var html = RenderViewAsString("Home", modelVm);

            TEMPLATE newtemplate = new TEMPLATE();

            newtemplate.dateCreation = DateTime.Now;
            newtemplate.url          = model.url;
            newtemplate.ftpUser      = model.ftpUser;
            newtemplate.ftpPassword  = model.ftpPassword;
            newtemplate.modeleId     = (Guid)Session["modeleId"];
            newtemplate.ip           = model.ip;
            newtemplate.userId       = _userId;
            newtemplate.PROJET       = db.PROJETS.Find(selectedProjetId);
            newtemplate.projetId     = selectedProjetId;
            var   selectedTheme = model.THEME.theme_name;
            THEME currentTheme  = db.THEMES.FirstOrDefault(x => x.theme_name.Contains(selectedTheme.TrimEnd()));

            if (currentTheme == null)
            {
                currentTheme = new THEME {
                    themeId = Guid.NewGuid(), theme_name = selectedTheme
                };
                db.THEMES.Add(currentTheme);
                db.SaveChanges();
            }

            newtemplate.THEME   = currentTheme;
            newtemplate.themeId = currentTheme.themeId;

            newtemplate.html = html;


            var results =
                newtemplate.templateId = Guid.NewGuid();

            db.TEMPLATEs.Add(newtemplate);
            try
            {
                res = db.SaveChanges();
                if (res > 0)
                {
                    var templateName = Session["TemplateName"].ToString();

                    int nb_menu = (Session["nbmenu"] == null) ? 1 : int.Parse(Session["nbmenu"].ToString());

                    CreateFiles(nb_menu, html);

                    //Send Ftp
                    string pathParent = Server.MapPath("~/Themes/" + templateName);
                    string pathCss    = pathParent + "/css/";
                    string pathImg    = pathParent + "/img";
                    string pathJs     = pathParent + "/js";
                    int    result     = SendToFtp(ftpdir, model.url, model.ftpUser, model.ftpPassword, pathCss, pathParent, pathImg, pathJs);

                    //return new FilePathResult(path, "text/html");
                    if (result == 0)
                    {
                        return(View("CreateTemplateConfirmation"));
                    }
                    else
                    {
                        return(View("ErrorException"));
                    }
                }
                else
                {
                    return(View("ErrorException"));
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorException"));
            }
        }
Example #7
0
        public ActionResult SaveTheme(MODELEViewModel model, HttpPostedFileBase logoUrl,
                                      HttpPostedFileBase menu1_paragraphe1_photoUrl, HttpPostedFileBase menu1_paragraphe2_photoUrl,
                                      HttpPostedFileBase menu2_paragraphe1_photoUrl, HttpPostedFileBase menu2_paragraphe2_photoUrl,
                                      HttpPostedFileBase menu3_paragraphe1_photoUrl, HttpPostedFileBase menu3_paragraphe2_photoUrl,
                                      HttpPostedFileBase menu4_paragraphe1_photoUrl, HttpPostedFileBase menu4_paragraphe2_photoUrl,
                                      HttpPostedFileBase photoALaUneUrl, HttpPostedFileBase favicone, FormCollection collection)
        {
            var templateName = Session["TemplateName"].ToString();

            if (!string.IsNullOrEmpty(collection["nbmenu"]))
            {
                string nbmenu = collection["nbmenu"];
                Session["nbmenu"] = nbmenu;
            }

            string path = Server.MapPath("~/Themes/" + templateName);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            else
            {
                DeleteFiles(path);
            }
            string pathimg = Server.MapPath("~/Themes/" + templateName + "/img/");

            DeleteFiles(pathimg);

            MODELE newmodel = new MODELE();

            newmodel.logoUrl  = SavePhoto(logoUrl, templateName);
            newmodel.favicone = SaveFavicon(favicone, templateName);

            /*Menu 1 */
            newmodel.menu1_titre = model.menu1_titre;

            newmodel.menu1_paragraphe1_titre    = model.menu1_paragraphe1_titre;
            newmodel.menu1_paragraphe1_photoUrl = SavePhoto(menu1_paragraphe1_photoUrl, templateName);
            newmodel.menu1_p1_alt   = AltPhoto(menu1_paragraphe1_photoUrl, templateName);
            newmodel.menu1_contenu1 = model.menu1_contenu1;

            newmodel.menu1_paragraphe2_titre    = model.menu1_paragraphe2_titre;
            newmodel.menu1_paragraphe2_photoUrl = SavePhoto(menu1_paragraphe2_photoUrl, templateName);
            newmodel.menu1_p2_alt           = AltPhoto(menu1_paragraphe2_photoUrl, templateName);
            newmodel.menu1_contenu2         = model.menu1_contenu2;
            newmodel.menu1_meta_description = model.menu1_meta_description;

            /*Menu 2 */
            newmodel.menu2_titre = model.menu2_titre;

            newmodel.menu2_paragraphe1_titre    = model.menu2_paragraphe1_titre;
            newmodel.menu2_paragraphe2_titre    = model.menu2_paragraphe2_titre;
            newmodel.menu2_paragraphe1_photoUrl = SavePhoto(menu2_paragraphe1_photoUrl, templateName);
            newmodel.menu2_p1_alt = AltPhoto(menu2_paragraphe1_photoUrl, templateName);
            newmodel.menu2_paragraphe2_photoUrl = SavePhoto(menu2_paragraphe2_photoUrl, templateName);
            newmodel.menu2_p2_alt           = AltPhoto(menu2_paragraphe2_photoUrl, templateName);
            newmodel.menu2_contenu1         = model.menu2_contenu1;
            newmodel.menu2_contenu2         = model.menu2_contenu2;
            newmodel.menu2_meta_description = model.menu2_meta_description;

            /*Menu 3 */
            newmodel.menu3_titre = model.menu3_titre;

            newmodel.menu3_paragraphe1_titre    = model.menu3_paragraphe1_titre;
            newmodel.menu3_paragraphe2_titre    = model.menu3_paragraphe2_titre;
            newmodel.menu3_paragraphe1_photoUrl = SavePhoto(menu3_paragraphe1_photoUrl, templateName);
            newmodel.menu3_p1_alt = AltPhoto(menu3_paragraphe1_photoUrl, templateName);
            newmodel.menu3_paragraphe2_photoUrl = SavePhoto(menu3_paragraphe2_photoUrl, templateName);
            newmodel.menu3_p2_alt           = AltPhoto(menu3_paragraphe2_photoUrl, templateName);
            newmodel.menu3_contenu1         = model.menu3_contenu1;
            newmodel.menu3_contenu2         = model.menu3_contenu2;
            newmodel.menu3_meta_description = model.menu3_meta_description;

            /*Menu 4 */

            newmodel.menu4_titre = model.menu4_titre;

            newmodel.menu4_paragraphe1_titre    = model.menu4_paragraphe1_titre;
            newmodel.menu4_paragraphe2_titre    = model.menu4_paragraphe2_titre;
            newmodel.menu4_paragraphe1_photoUrl = SavePhoto(menu4_paragraphe1_photoUrl, templateName);
            newmodel.menu4_p1_alt = AltPhoto(menu4_paragraphe1_photoUrl, templateName);
            newmodel.menu4_paragraphe2_photoUrl = SavePhoto(menu4_paragraphe2_photoUrl, templateName);
            newmodel.menu4_p2_alt           = AltPhoto(menu4_paragraphe2_photoUrl, templateName);
            newmodel.menu4_contenu1         = model.menu4_contenu1;
            newmodel.menu4_contenu2         = model.menu4_contenu2;
            newmodel.menu4_meta_description = model.menu4_meta_description;

            /*A la une*/
            newmodel.photoALaUneUrl = SavePhoto(photoALaUneUrl, templateName);
            newmodel.site_url       = model.site_url;

            newmodel.modeleId   = Guid.NewGuid();
            Session["modeleId"] = newmodel.modeleId;

            db.MODELEs.Add(newmodel);
            try
            {
                int res = db.SaveChanges();
                if (res > 0)
                {
                    Templates         val        = new Templates();
                    TEMPLATEViewModel templateVm = new TEMPLATEViewModel();
                    templateVm.ListProjet = val.GetListProjetItem();
                    templateVm.ListTheme  = val.GetListThemeItem();

                    return(View("CreateTemplate", templateVm));
                }

                else
                {
                    return(View("ErrorException"));
                }
            }
            catch (Exception ex)
            {
                return(View("Theme1"));
            }
        }