Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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 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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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());
        }
Esempio n. 7
0
        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));
        }
        public static String CommentaireDiv(Commentaires commentaire, int cpt)
        {
            var db = new Form115Entities();

            // le <div> externe
            var divTag = new TagBuilder("div");

            divTag.AddCssClass(String.Format("col-sm-offset-{0}", cpt));


            // le <div> interne FirstLine (présentation)
            var divFirstLineTag = new TagBuilder("div");

            // le <span> interne titre
            var spanTitreTag = new TagBuilder("span");

            spanTitreTag.InnerHtml = commentaire.Titre;

            // le <span> interne auteur
            var spanAuteurTag = new TagBuilder("span");

            spanAuteurTag.InnerHtml = commentaire.Utilisateurs.Prenom + commentaire.Utilisateurs.Nom;

            // le <span> interne date
            var spanDateTag = new TagBuilder("span");

            spanDateTag.InnerHtml = commentaire.DateCommentaire.ToShortDateString();

            // Contenu du div interne FirstLine (présentation)
            divFirstLineTag.InnerHtml = spanTitreTag.ToString() + spanAuteurTag.ToString() + spanDateTag.ToString(); //

            // le <p> interne texte
            var pTexteTag = new TagBuilder("p");

            pTexteTag.InnerHtml = commentaire.Commentaire;

            // le <div> pour le lien "Répondre"
            var divLastLineTag = new TagBuilder("div");

            // le <a> lien répondre
            var aRepondreTag = new TagBuilder("a");

            aRepondreTag.MergeAttribute("href", "#");
            aRepondreTag.AddCssClass("LienRepondre");
            aRepondreTag.MergeAttribute("id", String.Format("Commentaire-{0}", commentaire.IdCommentaire));
            aRepondreTag.InnerHtml = "Répondre";

            // Contenu du divpour le lien "Répondre"
            divLastLineTag.InnerHtml = aRepondreTag.ToString();

            // Contenu du div externe
            divTag.InnerHtml = divFirstLineTag.ToString() + pTexteTag.ToString() + divLastLineTag.ToString();

            return(divTag.ToString());
        }
Esempio n. 9
0
        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());
        }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
        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();
        }
Esempio n. 14
0
        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();
        }
Esempio n. 16
0
        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));
        }
Esempio n. 17
0
 public Search()
 {
     SearchResults = new Form115Entities().Produits;
 }
Esempio n. 18
0
        //public static void CommentairesDiv(List<Commentaires> commentaires, int? idCommentaire, int cpt, StringBuilder s)
        //{
        //    //if (cpt != 0)
        //    //{
        //    //    s.Append(String.Format("<div class=\"col-sm-offset-{0} partial_view_search_result\">", cpt));
        //    //}
        //    foreach (var com in commentaires.Where(c => c.IdCommentaireReference == idCommentaire).OrderBy(c=>c.DateCommentaire))
        //    {
        //       s.Append(CommentaireDiv(com, cpt));
        //       CommentairesDiv(commentaires, com.IdCommentaire, cpt+1, s);
        //    }
        //    //if (cpt != 0)
        //    //{
        //    //    s.Append("</div>");
        //    //}
        //}

        public static String CommentaireDiv(Commentaires commentaire) // int cpt
        {
            var db = new Form115Entities();

            // le <div> externe
            var divTag = new TagBuilder("div");

            //divTag.AddCssClass(String.Format("col-xs-offset-{0}", cpt));
            divTag.AddCssClass("Commentaire");


            // le <div> interne FirstLine (présentation)
            var divFirstLineTag = new TagBuilder("div");

            // le <span> interne titre
            var h5TitreTag = new TagBuilder("h5");

            h5TitreTag.InnerHtml = commentaire.Titre;
            h5TitreTag.AddCssClass("TitreCommentaire");
            h5TitreTag.AddCssClass("col-md-6 col-xs-4");

            // le <span> interne auteur
            var spanAuteurTag = new TagBuilder("b");

            spanAuteurTag.InnerHtml = String.Format("{0} {1}", commentaire.Utilisateurs.Prenom, commentaire.Utilisateurs.Nom);
            spanAuteurTag.AddCssClass("AuteurCommentaire");
            spanAuteurTag.AddCssClass("text-center");
            spanAuteurTag.AddCssClass("col-md-3 col-xs-4");

            // le <span> interne date
            var spanDateTag = new TagBuilder("i");

            spanDateTag.InnerHtml = commentaire.DateCommentaire.ToShortDateString();
            spanDateTag.AddCssClass("DateCommentaire");
            spanDateTag.AddCssClass("text-right");
            spanDateTag.AddCssClass("col-md-3 col-xs-4");

            // Contenu du div interne FirstLine (présentation)
            divFirstLineTag.InnerHtml = h5TitreTag.ToString() + spanAuteurTag.ToString() + spanDateTag.ToString(); //

            // le <p> interne texte
            var pTexteTag = new TagBuilder("p");

            pTexteTag.InnerHtml = commentaire.Commentaire;

            // le <div> pour le lien "Répondre"
            var divLastLineTag = new TagBuilder("div");

            // le <a> lien répondre
            var aRepondreTag = new TagBuilder("a");

            aRepondreTag.MergeAttribute("href", "#");
            aRepondreTag.AddCssClass("LienRepondre");
            aRepondreTag.MergeAttribute("id", String.Format("Commentaire-{0}", commentaire.IdCommentaire));
            aRepondreTag.InnerHtml = "Répondre";

            // Contenu du divpour le lien "Répondre"
            divLastLineTag.InnerHtml = aRepondreTag.ToString();
            divLastLineTag.AddCssClass("col-xs-offset-3");

            // Contenu du div externe
            divTag.InnerHtml = divFirstLineTag.ToString() + "<div class=\"clear\"></div>" + pTexteTag.ToString() + divLastLineTag.ToString();

            return(divTag.ToString());
        }