예제 #1
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);
        }
예제 #2
0
 public ActionResult Details(int id)
 {
     //Form115Entities db = new Form115Entities();
     //Hotels hotel = db.Hotels.Where(h => h.IdHotel == id).First();
     HotelViewModel hvm = new HotelViewModel
     {
         IdHotel = id
     };
     return View(hvm);
 }
예제 #3
0
 public ActionResult DetailsPeriode(int id, string startDate, string endDate)
 {
     //Form115Entities db = new Form115Entities();
     //Hotels hotel = db.Hotels.Where(h => h.IdHotel == id).First();
     HotelViewModel hvm = new HotelViewModel
     {
         IdHotel = id,
         DateDebut = startDate,
         DateFin = endDate
     };
     return View("Details", hvm);
 }
예제 #4
0
 public ActionResult Details(int id, string nav)
 {
     //Form115Entities db = new Form115Entities();
     //Hotels hotel = db.Hotels.Where(h => h.IdHotel == id).First();
     HotelViewModel hvm = new HotelViewModel
     {
         IdHotel = id,
         DisponibiliteMax = _db.Produits.Where(p => p.Sejours.Hotels.IdHotel == id)
                                         .Select(p => (p.NbPlaces - (p.Reservations.Count() != 0 ? p.Reservations.Sum(r => r.Quantity) : 0)))
                                         .Max(),
         Nav = nav
     };
     return View(hvm);
 }
예제 #5
0
        public JsonResult listeProduits(HotelViewModel hvm)
        {
            SearchBase s = new Search();
            if (hvm.DateIndifferente == null)
            {
                if (hvm.DateMarge == null)
                {
                    s = new SearchOptionDateDepart(s, hvm._dateDepart, hvm._dateDepart);
                }
                else
                {
                    s = new SearchOptionDateDepart(s, hvm._dateDepart, hvm._dateDepart.AddDays((double)hvm.DateMarge));
                }
            }
            s = new SearchOptionAPartirDAujourdHui(s);
            // TODO Attention ici il peut n'y avoir qu'une seule renseignée
            s = new SearchOptionDuree(s, hvm.DureeMini, hvm.DureeMaxi);
            s = new SearchOptionNbPers(s, hvm.NbPers);
            s = new SearchOptionPrixMax(s, hvm.PrixMaxi);
            s = new SearchOptionPrixMin(s, hvm.PrixMini);
            //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);
            ////}
            //    if (hvm.NbPers >= 0)
            //    {
            //        prods = prods.Where(p => ((p.NbPlaces - (p.Reservations.Count() != 0 ? p.Reservations.Sum(r => r.Quantity) : 0)) >= hvm.NbPers));
            //    }

            // 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
            // TODO : decorator pour l'hôtelk afin de le placer en premier
            var result = s.GetResult().Where(p => p.Sejours.Hotels.IdHotel == hvm.IdHotel)
                                       .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),
                                                            sejour =p.IdProduit
                                                        }
                                        );
            return Json(result, JsonRequestBehavior.AllowGet);
        }
예제 #6
0
 public ActionResult DetailsPeriode(int id, string startDate, string endDate)
 {
     //Form115Entities db = new Form115Entities();
     //Hotels hotel = _db.Hotels.Where(h => h.IdHotel == id).First();
     HotelViewModel hvm = new HotelViewModel
     {
         IdHotel = id,
         DateDebut = startDate,
         DateFin = endDate,
         DisponibiliteMax = _db.Produits.Where(p => p.Sejours.Hotels.IdHotel == id)
                                         .Select(p => (p.NbPlaces - (p.Reservations.Count() != 0 ? p.Reservations.Sum(r => r.Quantity) : 0)))
                                         .Max()
     };
     return View("Details", hvm);
 }