Ejemplo n.º 1
0
        private void ExportStopTimetableToFile(BackendContext db, Stop stop)
        {
            var          filename       = RemovePolishCharacters(RemoveNonAlphanumericCharacters(stop.Name));
            var          filepath       = AppDomain.CurrentDomain.BaseDirectory + "App_Data\\Exports\\" + filename + ".json";
            APITimetable apiTimetable   = APITimetableBuilder.Build(db, stop.Id);
            String       serializedStop = JsonConvert.SerializeObject(apiTimetable, jsonSerializerSettings);

            using (StreamWriter writer = new StreamWriter(filepath, false, Encoding.UTF8))
            {
                writer.Write(serializedStop);
                writer.Close();
            }
        }
Ejemplo n.º 2
0
        public JsonCamelCaseResult Timetable(int stopId, Boolean prettyPrint)
        {
            using (BackendContext db = new BackendContext())
            {
                // TODO: check if necessary
                db.Configuration.LazyLoadingEnabled = false;

                APITimetable result = APITimetableBuilder.Build(db, stopId);

                return(new JsonCamelCaseResult(result)
                {
                    PrettyPrint = prettyPrint
                });
            }
        }