Ejemplo n.º 1
0
        public List<Track> GetAllCars()
        {
            
            List<Track> results = new List<Track>();

            foreach (Track tk in objContext.Tracks)
            {
                Track newTrack = new Track();
                newTrack.Track_Id = tk.Track_Id;
                newTrack.Track_Length = tk.Track_Length;
                newTrack.Track_Name = tk.Track_Name;
                foreach (Unit un in tk.Units)
                {
                    Unit newUnit = new Unit();
                    newUnit.Track_Id = un.Track_Id;
                    newUnit.Unit_Id = un.Unit_Id;
                    newUnit.Unit_Name = un.Unit_Name;
                    newTrack.Units.Add(newUnit);
                }

                results.Add(newTrack);

             
            }

            return results;
        }
Ejemplo n.º 2
0
        public List<Yard> GetYardJSON()
        {
            List<Yard> json = new List<Yard>();
            foreach (Yard yd in objContext.Yards)
            {
                Yard newYard = new Yard();
                newYard.Yard_Id = yd.Yard_Id;
                newYard.Yard_Name = yd.Yard_Name;
                newYard.Yard_Location = yd.Yard_Location;
                foreach (Track tk in yd.Tracks)
                {
                    Track newTrack = new Track();
                    newTrack.Track_Id = tk.Track_Id;
                    newTrack.Track_Name = tk.Track_Name;
                    newYard.Tracks.Add(newTrack);
                    foreach (Unit un in tk.Units)
                    {
                        Unit newUnit = new Unit();
                        newUnit.Track_Id = un.Track_Id;
                        newUnit.Unit_Id = un.Unit_Id;
                        newUnit.Unit_Name = un.Unit_Name;
                        newTrack.Units.Add(newUnit);
                        foreach (UnitCar uc in un.UnitCars)
                        {
                            UnitCar newUC = new UnitCar();
                            newUC.Car_Id = uc.Car_Id;
                            newUC.Unit_Id = uc.Unit_Id;
                            newUnit.UnitCars.Add(newUC);
                            
                        }

                        json.Add(newYard);
                         
                    }
                   
                }
            }
            return json;
        }