public JsonResult SaveDataInDatabase(ArticleViewModel model)
        {
            var result = false;

            try
            {
                if (model.idArticle > 0)
                {
                    Article art = dc.Articles.SingleOrDefault(x => x.disponibilite == true && x.idArticle == model.idArticle);
                    art.description    = model.description;
                    art.refArticle     = model.refArticle;
                    art.libelleArticle = model.libelleArticle;
                    art.prix           = model.prix;
                    art.nbpieces       = model.nbpieces;
                    art.couleur        = model.couleur;
                    art.taille         = model.taille;
                    art.idCategorie    = model.idCategorie;
                    art.idType         = model.idType;
                    art.idMarque       = model.idMarque;
                    dc.SaveChanges();
                    result = true;
                }
                else
                {
                    Article art = new Article();
                    art.description    = model.description;
                    art.refArticle     = model.refArticle;
                    art.libelleArticle = model.libelleArticle;
                    art.prix           = model.prix;
                    art.nbpieces       = model.nbpieces;
                    art.couleur        = model.couleur;
                    art.taille         = model.taille;
                    art.idCategorie    = model.idCategorie;
                    art.idType         = model.idType;
                    art.idMarque       = model.idMarque;
                    art.disponibilite  = false;
                    dc.Articles.Add(art);
                    dc.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public ActionResult LoginAdmin(Admin admin)
        {
            iBoutiqureDBEntities4 db = new iBoutiqureDBEntities4();

            db.Admins.Add(admin);
            db.SaveChanges();
            ViewBag.message = "connexion avec succes";
            return(View());
        }
        public ActionResult DeleteUser(int id)
        {
            bool status = false;

            using (iBoutiqureDBEntities4 dc = new iBoutiqureDBEntities4())
            {
                var v = dc.Users.Where(a => a.idUser == id).FirstOrDefault();
                if (v != null)
                {
                    dc.Users.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(RedirectToAction("ListeUsers", "home/ListeUsers"));
            // return new JsonResult { Data = new { status = status } };
        }
        public ActionResult Deletem(int id)
        {
            using (iBoutiqureDBEntities4 db = new iBoutiqureDBEntities4())
            {
                {
                    Commande cmd = db.Commandes.Where(x => x.idCommande == id).FirstOrDefault <Commande>();
                    db.Commandes.Remove(cmd);
                    db.SaveChanges();
                    return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
                }



                //Commande cmd = db.Commandes.Where(x => x.idCommande == id).FirstOrDefault<Commande>();

                //iBoutiqureDBEntities2 db = new iBoutiqureDBEntities2();
                // var cmd=db.supprimer(id);

                //return Ok(cmd);
            }
        }
        public ActionResult Save(User us)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (iBoutiqureDBEntities4 dc = new iBoutiqureDBEntities4())
                {
                    if (us.idUser > 0)
                    {
                        //edit
                        var v = dc.Users.Where(a => a.idUser == us.idUser).FirstOrDefault();
                        if (v != null)
                        {
                            v.nom           = us.nom;
                            v.prenom        = us.prenom;
                            v.email         = us.email;
                            v.tel           = us.tel;
                            v.ville         = us.ville;
                            v.adresse       = us.adresse;
                            v.codePostal    = us.codePostal;
                            v.datenaissance = us.datenaissance;
                        }
                    }
                    else
                    {
                        //save
                        dc.Users.Add(us);
                    }
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(RedirectToAction("ListeUsers", "home/ListeUsers"));
            //new JsonResult { Data = new { status = status } };
        }