Esempio n. 1
0
        public ContentResult Geocode(string q, string codePays)
        {
            string list = "";

            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                IPays pays = Data.PaysDataAccess.GetPays(int.Parse(codePays));


                string rez = GoogleMapServices.GetJson(q, pays.CodePays2);

                Dictionary <string, object> rezMap = serializer.Deserialize <Dictionary <string, object> >(rez);
                if (((IDictionary <string, object>)rezMap["Status"])["code"] == "200")
                {
                    ArrayList placemarks = (ArrayList)rezMap["Placemark"];


                    foreach (var place in placemarks)                                    //2 placemarks
                    {
                        list += ((IDictionary <string, object>)place)["address"] + "\n"; // .Where(key;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(Content(list));//"text/json"
        }
Esempio n. 2
0
        public static string CountryFlagImgUrl(this HtmlHelper htmlHelper, IPays pays)
        {
            return(CountryFlagImgUrl(htmlHelper, pays, FlagSize.s48));
            // string codeIso = pays.CodePays2.ToLower();

            //return  htmlHelper.ViewContext.HttpContext.Server.MapPath("~Content/flag_iso_48/"+codeIso+".png");
        }
Esempio n. 3
0
        public static SelectList ListePays(string selectedPaysId, IList <string> listepays)
        {
            //IList<string> allPays = dataProvider.PaysDataAccess.GetAllPaysString();
            IList <IPays> allPaysE = (IList <IPays>)CovCake.UnCache("AllPays");

            if (allPaysE == null)
            {
                allPaysE = dataProvider.PaysDataAccess.GetAllPays().ToList();
                int cacheTime = CovCakeConfiguration.DefaultDataCacheExpiration;
                CovCake.Cache("AllPays", allPaysE, DateTime.Now.AddHours(cacheTime));
                // HttpRuntime.Cache.Insert("AllPays", allPaysE, null, DateTime.Now.AddHours(cacheTime), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            int selPaysId = 77;

            if (!selectedPaysId.IsNullOrEmpty())
            {
                int.TryParse(selectedPaysId, out selPaysId);//france
            }
            foreach (string item in listepays)
            {
                IPays insertP = allPaysE.Single(p => p.LibellePays == item);
                allPaysE.Remove(insertP);
                allPaysE.Insert(0, insertP);
            }
            // allPays.Insert(0, "------------------------");
            if (selectedPaysId.IsNullOrEmpty())
            {
                return(new SelectList(allPaysE, "IdPays", "LibellePays"));        // selectedP);
            }
            return(new SelectList(allPaysE, "IdPays", "LibellePays", selPaysId)); // selectedP);
            //  return new SelectList(allPays, selectedPaysId);
        }
Esempio n. 4
0
        public static string CountryFlagImgUrl(this HtmlHelper htmlHelper, IPays pays, FlagSize size)
        {
            string codeIso = pays.CodePays2.ToLower().Trim();
            string sz      = Enum.GetName(typeof(FlagSize), size).Replace("s", "");

            return("/Content/flag_iso_" + sz + "/" + codeIso + ".png");
        }
Esempio n. 5
0
 public static string Libelle(this IPays pays)
 {
     return((pays != null) ? pays.LibellePays : "");
 }
Esempio n. 6
0
 CarDealer(IPays pays)
 {
     _pays = pays;
 }
Esempio n. 7
0
 public static string CountryFlagImg(this  HtmlHelper htmlHelper, IPays pays)
 {
     return(htmlHelper.Image(htmlHelper.CountryFlagImgUrl(pays), ""));
 }
Esempio n. 8
0
        public ActionResult Create(AlerteViewData alerteViewData)
        {
            //Editer et Créer une alerte

            int?     paysId    = alerteViewData.paysArrive;
            DateTime?dateDebut = alerteViewData.dateDebut;
            //DateTime? dateFin = newAlerte.dateFin;
            int      moisFin = alerteViewData.moisFin ?? 0;
            int      moisDebut = alerteViewData.moisDebut ?? 0;
            int?     nbJours = alerteViewData.nbJours;// ?? 0;
            DateTime?periodeFin = null, periodeDeb = null;
            IPays    pays        = null;
            string   villeArrive = (alerteViewData.villeArrive.Trim().IsNullOrEmpty())? null : alerteViewData.villeArrive.Trim();

            if (moisDebut > 0 && moisFin < 1)
            {
                this.ModelState.AddModelError("moisFin", "Vous devez spécifier le mois de fin de période");
            }
            if (moisDebut > 0 && moisFin > 0)
            {
                int year = DateTime.Today.Year;

                periodeDeb = new DateTime(year, moisDebut, 1);
                if (moisFin < moisDebut)
                {
                    year++;                                    // si le mois de fin avant mois de début sa avance a l'année d'apres
                }
                periodeFin = new DateTime(year, moisFin++, 1); //au 1er du mois d'apres
            }


            if (paysId != null)
            {
                pays = Data.PaysDataAccess.GetPays(paysId.Value);
                if (pays == null)
                {
                    this.ModelState.AddModelError("paysArrive", "Le pays spécifié n'a pas été trouvé.");
                }
            }

            if (dateDebut == null && nbJours < 1)
            {
                this.ModelState.AddModelError("dateDebut", "Vous devez spécifier une date de départ ou un nombre de jour");
            }


            if (this.ModelState.IsValid)
            {
                //Insertion de l'alerte
                //TODO: Mettre l'insertion de l'alerte en fonction??

                IAlerte newAlert = Data.AlerteDataAccess.Create();
                newAlert.IdPays          = paysId;
                newAlert.NbJours         = nbJours;
                newAlert.UserId          = this.CurrentUserId;
                newAlert.PeriodeDebut    = periodeDeb;
                newAlert.PeriodeFin      = periodeFin;
                newAlert.DateDebutProjet = dateDebut;
                newAlert.VilleArrive     = villeArrive;

                newAlert.DateDernierEnvoi = this.CurrentUser.AccountCreationDate;//initialisation à la date de création du compte
                newAlert.DateCreation     = DateTime.Now;

                Data.AlerteDataAccess.InsertAlerte(newAlert);
                return(RedirectToAction("CreateSuccess")); //View("CreateSuccess");
            }

            return(View(alerteViewData));
        }
Esempio n. 9
0
        public ActionResult Search(SearchProjetParams searchArgs, int?page)
        {
            const int offsetDaysDate  = 10;
            const int offsetDaysJours = 5;

            try
            {
                this.ModelState.Clear();
                page = page ?? 0;
                page = (page >= 0) ? page : 0;

                searchArgs.paysArrive = searchArgs.paysArrive.Trim();
                this.SetPageTitle("Voyages vers " + searchArgs.paysArrive);

                string query = searchArgs.paysArrive;
                if (string.IsNullOrEmpty(query))
                {
                    searchArgs.paysArrive = "~Tous~";
                }
                else if (searchArgs.nbJours != null && (searchArgs.nbJours < 1 || searchArgs.nbJours > 365))
                {
                    this.ModelState.AddModelError("_FORM", "Le nombre de jour doit être compris entre 1 et 365");
                }


                //   searchArgs.paysArrive = searchArgs.paysArrive.ToTitleCase();
                IQueryable <IProjet> completeList;

                //TODO: Faire une recherche en enlevant les accents
                IPays pays = Data.PaysDataAccess.GetPaysFr(query);
                // pays = Data.PaysDataAccess.GetPaysFrNoAccent(query);
                if (!string.IsNullOrEmpty(query) && pays == null)
                {
                    ModelState.AddModelError("_FORM", "Aucun voyages ne concerne ce pays");
                    //TempData["noresult"] = true;
                    //return RedirectToAction("Liste");
                }
                if (ModelState.IsValid)
                {
                    int nbJours = searchArgs.nbJours ?? 0;
                    //TODO: pas comprendre sa...
                    DateTime?dateDepart = searchArgs.dateDebut; //(searchArgs.dateDebut.HasValue) ? searchArgs.dateDebut.Value.AddDays(nbJours) as DateTime? : null;

                    // IQueryable< IPays> pays = Data.PaysDataAccess.GetAllPays().Where(p => p.LibellePays.ToLower().Contains(query));

                    completeList = Data.ProjetDataAccess.GetAllProjets();
                    if (pays != null)
                    {
                        completeList = completeList.ProjetsTo(pays.IdPays);
                    }

                    if (dateDepart != null)
                    {   //TODO: verifier que le projet n'est pas complet ou deja réalisé
                        completeList = completeList
                                       .ProjetsDateDebutBetween(dateDepart.Value.AddDays(-offsetDaysDate), dateDepart.Value.AddDays(offsetDaysDate));
                        //.Where(p => p.PaysArriveEntity.LibellePays.ToLower().Contains(query))
                    }
                    if (nbJours > 0)
                    {
                        //Inclus les projets incertains
                        completeList = completeList //Data.ProjetDataAccess.GetAllProjets()
                                                    //.Where(p => p.PaysArrive.LibellePays.ToLower().Contains(query)
                                       .Where(p => nbJours - offsetDaysJours <= p.NbJours && p.NbJours <= nbJours + offsetDaysJours);
                    }

                    completeList = completeList.OrderBy(p => p.DateDebut);
                    //IQueryable<IProjet> nonOutdated = Data.ProjetDataAccess.GetAllProjets().ProjetsNonOutdated().OrderBy(p => p.DateDebut);
                    //if(nonOutdated.Count() > 5)
                    if (completeList.Count() == 0)
                    {
                        //Afficher tout ls voyage si aucune réponse na été trouvée
                        completeList         = ProjetBasicList();
                        ViewData["noresult"] = true;
                        TempData["noresult"] = true;
                        //return RedirectToAction("Liste");
                    }

                    ListeProjetViewData projets = new ListeProjetViewData()
                    {
                        ListeProjets    = completeList.ToPagedList(page.Value, NB_PROJETS_PAR_PAGE_LISTE),
                        IsSearchResults = true,
                        SearchParams    = searchArgs
                    };



                    return(View("Liste", projets));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("_FORM", "Une erreur est apparue lors de votre recherche");
            }


            ListeProjetViewData basicListeProjets = new ListeProjetViewData()
            {
                ListeProjets    = ProjetBasicList().ToPagedList(page.Value, NB_PROJETS_PAR_PAGE_LISTE),
                IsSearchResults = true,
                SubstituteListe = true,
                SearchParams    = searchArgs
            };

            return(View("Liste", basicListeProjets));//(ListeProjetsViewData)ViewData.Model);
        }