示例#1
0
        public IHttpActionResult GetStationSNCFId(string name)
        {
            string idSncf;
            var    search = (from o in db.Station
                             where o.name.ToLower() == name.ToLower()
                             select o).FirstOrDefault();

            if (search.id_sncf == null)
            {
                idSncf         = JourneyProvider.GetIDFromPlace(name);
                search.id_sncf = idSncf;
                db.SaveChanges();
            }
            return(Ok(search.id_sncf));
        }
示例#2
0
        public IHttpActionResult GetSuperTrips(string departureStation, string arrivalStation, string stringDate, bool isArrival)
        {
            DateTime         date       = DateTime.ParseExact(stringDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
            DateTime         verifDate  = date.AddHours(5);
            List <SuperTrip> superTrips = new List <SuperTrip>();
            int departure_id            = StationProvider.GetStationIdByName(departureStation);
            int arrival_id = StationProvider.GetStationIdByName(arrivalStation);
            var query      = from o in db.SuperTrip
                             where o.id_departure_station == departure_id && o.id_arrival_station == arrival_id && o.departure_date >= date && o.departure_date <= verifDate
                             select o;
            var limitedquery = query.Take(4);

            if (query.Count() < 4)
            {
                superTrips = JourneyProvider.GetMultiplesJourneys(departureStation, arrivalStation, date.ToString("yyyyMMddTHHmmss"), isArrival);
            }
            else
            {
                superTrips = query.ToList <SuperTrip>();
            }
            return(Ok(ConvertToSuperTripViewModel(superTrips)));
        }