Example #1
0
        public void Update(Tarif tarif)
        {
            Tarif t = DalGenerique <Tarif> .GetInstance().GetById(tarif.Id);

            t.Horaire      = tarif.Horaire;
            t.HeureDebut   = tarif.HeureDebut;
            t.HeureFin     = tarif.HeureFin;
            t.IsFirstDay   = tarif.IsFirstDay;
            t.Prix         = tarif.Prix;
            t.Tarification = tarif.Tarification;
            db.SaveChanges();
        }
Example #2
0
        public static List <Parking> GetAll()
        {
            List <Parking> listeParkings = new List <Parking>();
            var            client        = new WebClient();

            client.Encoding = Encoding.UTF8;
            var        adresse    = @"http://data.citedia.com/r1/parks/?crs=EPSG:4326";
            var        json       = client.DownloadString(adresse);
            RootObject rootObject = JsonConvert.DeserializeObject <RootObject>(json);

            //Donnees des parking
            foreach (var park in rootObject.parks)
            {
                if (park != null && park.parkInformation != null && park.parkInformation.free >= 10)
                {
                    listeParkings.Add(new Parking
                    {
                        Identifiant  = park.id,
                        Nom          = park.parkInformation.name,
                        Statut       = park.parkInformation.status,
                        PlacesMax    = park.parkInformation.max,
                        PlacesLibres = park.parkInformation.free
                    });
                }
            }

            //Coordonnees des parkings
            foreach (var feature in rootObject.features.features)
            {
                var parkingSelected = listeParkings.FirstOrDefault(f => f.Identifiant == feature.id);
                if (parkingSelected != null)
                {
                    parkingSelected.Coordonnees = FormatCoordonnees(feature.geometry.coordinates);
                }
            }

            //TexteTarifs et adresses des parkings
            List <ParkingPrice> listeTarifs = SplitCSV(@"http://data.citedia.com/r1/parks/timetable-and-prices");

            foreach (var tarif in listeTarifs)
            {
                Parking p = listeParkings.FirstOrDefault(f => f.Identifiant == tarif.Id);
                if (p != null)
                {
                    p.TexteHoraires = tarif.Horaires;
                    p.Adresse       = tarif.Adresse;
                    p.TexteTarifs   = tarif.Tarifs;
                }
            }

            foreach (var parking in listeParkings)
            {
                parking.Adresse    = DalGoogleMaps.GetAddressFromLatLng(parking.Coordonnees);
                parking.LastUpdate = DateTime.Now;
            }

            //TODO Creer objets horaires et tarifs

            //Horaires
            Horaire h = new Horaire();



            //Tarifs
            Tarif t = new Tarif();


            SaveParkings(listeParkings);

            return(listeParkings);
        }