public ActionResult UpdateReservation2(Excursion.Portail.Models.ReservationModel2 reservation)
        {
            //if (ModelState.IsValid)
            //{
            Reservation reserv = reservationRepository.FindOne(x => x.ReservationID == reservation.ReservationID);

            // recherche SortieID
            string[] tab        = reservation.Sortie.Split("-".ToCharArray());
            float    hdp        = Convert.ToSingle(tab[3]);
            string   nom        = tab[0].ToString();
            string   typeexc    = tab[1].ToString();
            DateTime datesortie = Convert.ToDateTime(tab[5]);

            if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "fr")
            {
                SortieParSemaine sortie = sortieParSemaineRepository.FindOne(x => x.HeureDepart == hdp && x.Excursion.Nom_fr == nom && x.Jour.Date == datesortie && x.TypeExc.Type == typeexc && x.Excursion.CentreID == SessionData.CurrentUser.CentreID);
                reserv.SortieID = sortie.SortieID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "de")
            {
                SortieParSemaine sortie = sortieParSemaineRepository.FindOne(x => x.HeureDepart == hdp && x.Excursion.Nom_de == nom && x.Jour.Date == datesortie && x.TypeExc.Type == typeexc && x.Excursion.CentreID == SessionData.CurrentUser.CentreID);
                reserv.SortieID = sortie.SortieID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "en")
            {
                SortieParSemaine sortie = sortieParSemaineRepository.FindOne(x => x.HeureDepart == hdp && x.Excursion.Nom_en == nom && x.Jour.Date == datesortie && x.TypeExc.Type == typeexc && x.Excursion.CentreID == SessionData.CurrentUser.CentreID);
                reserv.SortieID = sortie.SortieID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "it")
            {
                SortieParSemaine sortie = sortieParSemaineRepository.FindOne(x => x.HeureDepart == hdp && x.Excursion.Nom_it == nom && x.Jour.Date == datesortie && x.TypeExc.Type == typeexc && x.Excursion.CentreID == SessionData.CurrentUser.CentreID);
                reserv.SortieID = sortie.SortieID;
            }


            reserv.DateModification = DateTime.Now.Date;
            reserv.HotelID          = hotelRepository.FindOne(x => x.Nom == reservation.Hotel && x.Region.Zone.CentreID == SessionData.CurrentUser.CentreID).HotelID;

            reserv.Etat = "M";

            reserv.LangueID    = langueRepository.FindOne(x => x.NomLangue == reservation.Langue).LangueID;
            reserv.NumTicket   = reservation.NumTicket;
            reserv.PointDepart = reservation.PointDepart;
            reserv.NbreAdultes = reservation.NbreAdultes;
            reserv.NbreEnfants = reservation.NbreEnfants;
            reserv.NbreBebes   = reservation.NbreBebes;
            reserv.Observation = reservation.Observation;
            reserv.NumChamb    = reservation.NumChamb.ToString();
            if ((bool)reservation.Paye)
            {
                reserv.Paye         = reservation.Paye;
                reserv.DatePayement = DateTime.Now.Date;
            }
            reservationRepository.Update(reserv);
            reservationRepository.Save();
            //}
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult Ajouter(Excursion.Portail.Models.Sortie sortie, string Type, string Excursion, string Etat)
        {
            Excursion.Data.SortieParSemaine st = new SortieParSemaine();
            st.HeureDepart = sortie.HeureDepart;
            st.TypeExcID   = typeExcRepository.FindOne(x => x.Type == Type).TypeExcID;
            if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "fr")
            {
                st.ExcursionID = excursionRepository.FindOne(x => x.Nom_fr == Excursion).ExcursionID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "de")
            {
                st.ExcursionID = excursionRepository.FindOne(x => x.Nom_de == Excursion).ExcursionID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "en")
            {
                st.ExcursionID = excursionRepository.FindOne(x => x.Nom_en == Excursion).ExcursionID;
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "it")
            {
                st.ExcursionID = excursionRepository.FindOne(x => x.Nom_it == Excursion).ExcursionID;
            }

            Excursion.Data.Jour jour = new Jour();
            if (Etat == "Valide")
            {
                jour.Etat = "V";
            }
            else
            {
                jour.Etat = "N";
            }
            jour.Date = sortie.DateSortie;
            int NumJour = 1 + (int)sortie.DateSortie.DayOfWeek;

            jour.NumeroJ = NumJour;
            jourRepository.Add(jour);
            jourRepository.Save();

            st.JourID = jour.JourID;

            sortieParSemaineRepository.Add(st);
            sortieParSemaineRepository.Save();


            #region dropdownlist
            var SysLst = new List <string>();
            if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "fr")
            {
                var SysQry = from b in excursionRepository.GetAll()
                             select b.Nom_fr;
                SysLst.AddRange(SysQry.Distinct());
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "en")
            {
                var SysQry = from b in excursionRepository.GetAll() select b.Nom_en;
                SysLst.AddRange(SysQry.Distinct());
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "de")
            {
                var SysQry = from b in excursionRepository.GetAll() select b.Nom_de;
                SysLst.AddRange(SysQry.Distinct());
            }
            else if (MvcGlobalisationSupport.CultureManager.GetLanguage() == "it")
            {
                var SysQry = from b in excursionRepository.GetAll() select b.Nom_it;
                SysLst.AddRange(SysQry.Distinct());
            }
            ViewBag.ExcursionList = new SelectList(SysLst);

            var SysLst1 = new List <string>();
            var SysQry1 = from b in typeExcRepository.GetAll()
                          select b.Type;
            SysLst1.AddRange(SysQry1.Distinct());
            ViewBag.TypeList = new SelectList(SysLst1);

            var SysLst2 = new List <string>();
            SysLst2.Add("Valide");
            SysLst2.Add("Non Valide");
            ViewBag.EtatList = new SelectList(SysLst2);

            #endregion
            return(View());
        }