public string UpdateFacture(string id)
        {
            try
            {
                var facture = db.FACTUREs.Where(x => x.factureId.ToString() == id).SingleOrDefault();

                facture.etat = (facture.etat == true) ? false : true;

                var commandesFacturer = db.COMMANDEs.Where(x => x.factureId.ToString() == id).ToList();
                foreach (var commande in commandesFacturer)
                {
                    var status = (facture.etat == true) ? db.STATUT_COMMANDE.SingleOrDefault(s => s.statut_cmde.Contains("Payé")) : db.STATUT_COMMANDE.SingleOrDefault(s => s.statut_cmde.Contains("Facturé"));;
                    commande.STATUT_COMMANDE = status;
                    db.SaveChanges();
                }

                var res = db.SaveChanges();
                return(res.ToString());
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
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"));
            }
        }