public ActionResult Commenter(CommentaireViewModels cvm) { var db2 = new BestArtEntities(); var iduserASP = db.AspNetUsers.Where(x => x.Email == User.Identity.Name).Select(x => x.Id).FirstOrDefault(); var user = db.Utilisateurs.Where(x => x.IdAsp == iduserASP).FirstOrDefault(); var Com = new Commentaire() { Texte = cvm.ComTexte, UserRef = user.IdUtilisateur, DateComm = DateTime.Now, }; if (cvm.ComCom == 0) // Commentaire sur le Produit { Com.ProduitRef = cvm.ComProduit; Com.Num = db2.Commentaire.Where(c => c.ProduitRef == cvm.ComProduit).Count() + 1; } else // Reponse a un Commentaire { Com.CommRef = cvm.ComCom; Com.Num = db2.Commentaire.Where(c => c.CommRef == cvm.ComCom).Count() + 1; } db2.Commentaire.Add(Com); var P = db2.Produits.Where(p => p.IdProduit == cvm.ComProduit).FirstOrDefault(); db2.SaveChanges(); return View("Detail", P); }
public PartialViewResult Categorie(string id) { var db=new BestArtEntities(); var idcat = Int32.Parse(id); var cat=db.Categories.Where(c=>c.IdCategorie==idcat).FirstOrDefault(); return PartialView("_Categorie", cat); }
// GET: Admin/Statistique public ActionResult Index() { BestArtEntities db = new BestArtEntities(); ViewBag.min = db.Visibiliter.Min(x => x.DateVis); ViewBag.max = db.Visibiliter.Max(x => x.DateVis); return View(); }
public JsonResult GetJSONPROD(string id) { var db = new BestArtEntities(); int idtempo = int.Parse(id); var LR = db.Produits.Where(p => p.IdProduit == idtempo) .Select(p => new { prod = p.Nom, prix = p.Prix, stock = p.Stock }) .FirstOrDefault(); return Json(LR, JsonRequestBehavior.AllowGet); }
public static List<Commande> giveMeList() { var db = new BestArtEntities(); var listCommande = new List<Commande>(); var collection = db.Commandes; foreach(var item in collection) { var comm = new Commande(item); listCommande.Add(comm); } return listCommande; }
public JsonResult GetJSONStatistique(string id) { BestArtEntities db = new BestArtEntities(); var val = id.Split('-'); int min = int.Parse(val[0]); int max = int.Parse(val[1]); var V = db.Visibiliter.Where(pt => pt.DateVis >= new DateTime(min, 1, 1) && pt.DateVis < new DateTime(max, 12, 31)) .Join(db.Produits, pt => pt.ProduitRef, p => p.IdProduit, (pt, p) => new { pt.DateVis, p.Pays }) .GroupBy(x => x.Pays) .Select(g => new { Nom = g.Key.Name.Trim(), NbVis = g.Count() }) .OrderBy(x => x.Nom); return Json(V, JsonRequestBehavior.AllowGet); }
// GET: Panier public ActionResult Index() { var db = new BestArtEntities(); //obligattion de crée une nouvelle connexion a chaque fois car sinon la mise a jour des donnée utilisateur ne ce fait pas var pvm = new PanierViewModels() { NbCommande = 0, NbCommandeFid = db.Marketing.Select(m => m.NbreCommandePourReduc).FirstOrDefault(), }; if (User.Identity.IsAuthenticated) { var iduserASP = db.AspNetUsers.Where(x => x.Email == User.Identity.Name).Select(x => x.Id).FirstOrDefault(); var user = db.Utilisateurs.Where(x => x.IdAsp == iduserASP).FirstOrDefault(); pvm.NbCommande = user.NbCommande ?? 0; } return View(pvm); }
public static SearchViewModel InitializeSVM() { var db = new BestArtEntities(); SearchViewModel svm = new SearchViewModel(); svm.ListeCategorie = new List<SelectListItem>(); var liste = db.Categories.OrderBy(x => x.Libelle).ToList(); foreach (var item in liste) { svm.ListeCategorie.Add(new SelectListItem() { Text = item.Libelle, Value = item.IdCategorie.ToString() }); } svm.ListeContinents = new List<SelectListItem>(); var listeCont = db.Continents.OrderBy(x => x.name).ToList(); foreach (var cont in listeCont) { svm.ListeContinents.Add(new SelectListItem() { Text = cont.name, Value = cont.idContinent.ToString() }); } return svm; }
public Search() { SearchAnnonces = new BestArtEntities().Produits; }