public override IEnumerable<Produits> GetResult()
        {
            var db = new Form115Entities();

            if (_idVille != 0)
            {
                return SearchBase.GetResult().Where(p => p.Sejours.Hotels.Villes.idVille == _idVille);
            }
            else if (_idPays != null && _idPays != "0")
            {
                return SearchBase.GetResult()
                                .Where(p => p.Sejours.Hotels.Villes.Pays.CodeIso3 == _idPays);
            }
            else if (_idRegion != 0)
            {
                return SearchBase.GetResult()
                                .Where(p => p.Sejours.Hotels.Villes.Pays.Regions.idRegion == _idRegion);
            }
            else if (_idContinent != 0)
            {
                return SearchBase.GetResult()
                                .Where(p => p.Sejours.Hotels.Villes.Pays.Regions.Continents.idContinent == _idContinent);
            }
            else
            {
                return SearchBase.GetResult();//))
            }
        }
        public static List<SearchResutPartialViewItem> GetSearchResult(SearchViewModel svm)
        {
            Form115Entities db = new Form115Entities();

            // Search et SearchOption héritent de SearchBase
            SearchBase s = new Search();
            s = new SearchOptionDestination(s, svm.Continent, svm.Region, svm.Pays, svm.Ville);
            //s = new SearchOptionDateDepart(s, svm.DateDepart);
            s = new SearchOptionDuree(s, svm.Duree);
            s = new SearchOptionNbPers(s, svm.NbPers);
            s = new SearchOptionCategorie(s, svm.Categorie);
            s = new SearchOptionPrixMax(s, svm.PrixMax);
            s = new SearchOptionPrixMin(s, svm.PrixMin);

            // Intégration de DateDepart > DateTime.Now ici car on n'est pas intéressé par un produit périmé
            return s.GetResult()
                    .Where(p => p.DateDepart >= DateTime.Now)
                    .GroupBy(p => p.Sejours.Hotels.IdHotel,
                             p => p,
                             (key, g) => new SearchResutPartialViewItem
                                             {
                                                 Hotel = db.Hotels.Where(h => h.IdHotel == key).FirstOrDefault(),
                                                 Produits = g.ToList()
                                             })
                    .ToList();
        }
        public JsonResult listeProduits(HotelViewModel hvm)
        {
            Form115Entities db = new Form115Entities();
            var prods = db.Produits.Where(p => p.Sejours.IdHotel == hvm.IdHotel)
                            .Where(p=>p.Sejours.Duree >= hvm.DureeMinSejour) ;
            // TODO Attention aux filtres concurents pour le dateDebut
            if (hvm.DureeMaxSejour != null) {
                prods = prods.Where(p=>p.Sejours.Duree<=hvm.DureeMaxSejour) ;
            }
            if (hvm._dateDepart!=null) {
                prods = prods.Where(p=>p.DateDepart >= hvm._dateDepart) ;
            }
            //if (hvm._dateDebut != null)
            //{
                prods = prods.Where(p => p.DateDepart >= hvm._dateDebut);
            //}
            ////if (hvm._dateFin != null)
            //{
                prods = prods.Where(p => p.DateDepart <= hvm._dateFin);
            //}

            // HACK AsEnumerable avant le select ? Sinon ATTENTION, le nb_restants ne sera
            // pas à jour pour les prouits n'ayant pas de réservation, nécessite opérateur ternaire poutr jointure externe
            var result = prods.AsEnumerable().Select(p => new {
                                date = p.DateDepart.ToString("dd/MM/yyyy"),
                                duree = p.Sejours.Duree,
                                prix = p.Prix,
                                promotions = p.Promotion,
                                prixSolde = p.PrixSolde,
                                nb_restants = p.NbPlaces - p.Reservations.Sum(r => r.Quantity)
                            });
            return Json(result, JsonRequestBehavior.AllowGet);
        }
 public override IEnumerable<Produits> GetResult()
 {
     var db = new Form115Entities();
     return _nbPersonnes.HasValue
         ? SearchBase.GetResult()
                      .Where(p => ((p.NbPlaces - (p.Reservations.Count() != 0 ? p.Reservations.Sum(r => r.Quantity) : 0)) >= _nbPersonnes))
         : SearchBase.GetResult();
 }
 public static Dictionary<int, string> GetListeContinents()
 {
     Form115Entities db = new Form115Entities();
     return db.Continents.Where( c => db.Hotels
                                                         .Select(h => h.Villes.Pays.Regions.idContinent)
                                                         .Contains(c.idContinent))
                                         .Select(c => new { Key = c.idContinent, Value = c.name })
                                         .ToDictionary(x => x.Key, x => x.Value);
 }
Exemple #6
0
 //// TODO nompbre de reservations sur les x derniers jours => sauvegardés les dates des réservations en BDD
 //public int NbReservations(int periode)
 //{
 //    return _db.Reservations.Where(r => r.Produits.Sejours.IdHotel == 1002 TimeSpan
 //                                        && (DateTime.Now - r.DateReservation).TotalDays >= periode)
 //                           .Select(r => r.Quantity).Sum();
 //}
 public void ajouterPromotion(Form115Entities db, Promotions promo)
 {
     bool commencePendantExistant = Promotions.Where(p => p.DateDebut <= promo.DateDebut && p.DateFin >= promo.DateDebut).Any();
     bool terminePendantExistant = Promotions.Where(p => p.DateDebut <= promo.DateFin && p.DateFin >= promo.DateFin).Any();
     if (commencePendantExistant || terminePendantExistant)
     {
         throw new Exception();
     }
     else
     {
         db.Promotions.Add(promo);
     }
 }
 public JsonResult getStatsJson()
 {
     var db = new Form115Entities() ;
     var result = db.HotelTracking
                     .Where(pt => pt.DateHT >= new DateTime(2015, 8, 1) && pt.DateHT < new DateTime(2015, 9, 1))
                     .Join(db.Hotels,pt => pt.IdHotel,p => p.IdHotel,(pt, p) => new { pt.DateHT, p.Villes.Pays })
                     .GroupBy(x => x.Pays)
                     .Select(g => new { Nom = g.Key.Name.Trim(), NbVis = g.Count() })
                     .OrderBy(x => x.Nom) ;
                     //.ThenBy(x => x.Nom)
                     //.Take(10)
     return Json(result, JsonRequestBehavior.AllowGet);
 }
        public PartialViewResult Statistiques()
        {
            var db = new Form115Entities();

            var listProduit = db.Produits.Where(x => x.DateDepart > DateTime.Now).Count();
            var listUtilisateurs = db.Utilisateurs.Count();

            //créer une liste avec résultats
            var result = new List<int>{
                listProduit, listUtilisateurs
            };

            return PartialView("_Statistiques", result);
        }
Exemple #9
0
        //// TODO nompbre de reservations sur les x derniers jours => sauvegardés les dates des réservations en BDD
        //public int NbReservations(int periode)
        //{
        //    return _db.Reservations.Where(r => r.Produits.Sejours.IdHotel == 1002 TimeSpan
        //                                        && (DateTime.Now - r.DateReservation).TotalDays >= periode)
        //                           .Select(r => r.Quantity).Sum();
        //}


        public void ajouterPromotion(Form115Entities db, Promotions promo)
        {
            bool commencePendantExistant = Promotions.Where(p => p.DateDebut <= promo.DateDebut && p.DateFin >= promo.DateDebut).Any();
            bool terminePendantExistant  = Promotions.Where(p => p.DateDebut <= promo.DateFin && p.DateFin >= promo.DateFin).Any();

            if (commencePendantExistant || terminePendantExistant)
            {
                throw new Exception();
            }
            else
            {
                db.Promotions.Add(promo);
            }
        }
        public PartialViewResult Statistiques()
        {
            var db = new Form115Entities();

            var listProduitVisites = db.HotelTracking
                    .GroupBy(h=>h.Hotels.Nom)
                        .Select(g => new { NomHotel = g.Key, NbVis = g.Count() })
                .OrderByDescending(x => x.NbVis)
                 .Take(10)
                 .AsEnumerable()
                 .Select(x => new Tuple<string, int>(x.NomHotel, x.NbVis))
                 .ToList();

            return PartialView("_AdminStats", listProduitVisites);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var db = new Form115Entities();

            var ap = filterContext.ActionParameters.First();

            var ht = new HotelTracking
            {
                DateHT = DateTime.Now,
                IdHotel = (int)ap.Value
            };

            db.HotelTracking.Add(ht);

            db.SaveChanges();
        }
        public PartialViewResult BestPromo()
        {
            var db = new Form115Entities();

            var lp = db.Promotions
                .Where(r=>r.Hotels.Sejours
                    .Where(s=>s.Produits
                     .Where(p => p.DateDepart <= r.DateFin && p.DateDepart >= r.DateDebut && p.DateDepart > DateTime.Now).Any()).Any())
                     .OrderByDescending (x=> x.Valeur);

            var countPromo=lp.Count();

            var listPromo = lp.Take(5).ToList();

            //.Select(x => new Tuple<string, int>(x.Marque, x.Nombre))
            var result = new Tuple<List<Promotions>, int> (listPromo, countPromo);

            return PartialView("_BestPromo",result);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var db = new Form115Entities();

            // Accès au paramètre : id vaut IdHotel
            var ap = filterContext.ActionParameters.First();
            // var parmName = ap.Key // normalement id
            // var paramValue = (int)ap.Value;

            var ht = new HotelTracking
            {
                DateHT = DateTime.Now,
                IdHotel = (int)ap.Value
            };

            db.HotelTracking.Add(ht);

            db.SaveChanges();
        }
Exemple #14
0
 public Search()
 {
     SearchResults = new Form115Entities().Produits;
 }
 public JsonResult GetJSONSejour()
 {
     var db = new Form115Entities();
     var result = db.Produits
          .Select(d => new { Sejour = d.IdSejour, NomHotel = d.Sejours.Hotels.Nom, Ville = d.Sejours.Hotels.Villes.name, Pays = d.Sejours.Hotels.Villes.Pays.Name }).ToList();
     return Json(result, JsonRequestBehavior.AllowGet);
 }
 public JsonResult GetJSONHotel(int id)
 {
     var db = new Form115Entities();
     var result = db.Sejours
         .Where(d => d.IdSejour == id)
         .Select(d => new { Hotel = d.Hotels.IdHotel, NomHotel = d.Hotels.Nom, Ville = d.Hotels.Villes.name, Pays = d.Hotels.Villes.Pays.Name }).OrderBy(x => x.Ville).ToList();
     return Json(result, JsonRequestBehavior.AllowGet);
 }
        internal static List<SearchResutPartialViewItem> OrderingGroupResult(SearchBase s)
        {
            Form115Entities db = new Form115Entities();

            return  s.GetResult()
                    .GroupBy(p => p.Sejours.Hotels.IdHotel,
                             p => p,
                             (key, g) => new SearchResutPartialViewItem
                             {
                                 Hotel = db.Hotels.Where(h => h.IdHotel == key).FirstOrDefault(),
                                 Produits = g.ToList()
                             })
                    .ToList();
        }
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
                var result = await UserManager.CreateAsync(user, model.Password);
                
                

                if (result.Succeeded)
                {
                    var db = new Form115Entities();
                    var idtt = new Utilisateurs { Nom = model.Nom, Prenom = model.Prenom, InscritLettreInfo = model.Reponse, IdAspNetUsers = user.Id };
                    db.Utilisateurs.Add(idtt);
                    await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);

                    // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                    // Envoyer un message électronique avec ce lien
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                    db.SaveChanges();
                    return RedirectToAction("Index", "Home");
                }
                AddErrors(result);
            }

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return View(model);
        }