public ActionResult AddStation(AdminModel modelIn)
        {
            var lineIn = _lineBll.GetLineById(modelIn.Line.Id);

            var stationInDb = new DbStation()
            {
                StationName  = modelIn.Station.StationName,
                NumberOnLine = modelIn.Station.NumberOnLine,
                TrainLine    = lineIn
            };

            var stationIn = new RepositoryModelStation()
            {
                StationName  = modelIn.Station.StationName,
                NumberOnLine = modelIn.Station.NumberOnLine,
                TrainLine    = lineIn
            };

            _stationBll.AddStation(stationIn);

            lineIn.Stations.Add(stationInDb);
            _lineBll.UpdateLine(lineIn);

            ViewBag.line = lineIn;

            var model = new AdminModel()
            {
                Line = lineIn
            };

            ViewBag.line  = lineIn;
            ViewBag.added = "true";
            return(View("EditLine", model));
        }
 public bool UpdateStation(int id, RepositoryModelStation stationIn)
 {
     if (id == 0)
     {
         return(false);
     }
     return(stationIn != null);
 }
        public bool UpdateStation(int id, RepositoryModelStation stationIn)
        {
            var station = _databaseContext.Stations.Find(id);

            station.StationName = stationIn.StationName;
            _databaseContext.Stations.Update(station);
            _databaseContext.SaveChanges();
            return(true);
        }
        public bool AddStation(RepositoryModelStation station)
        {
            var dbStation = new DbStation()
            {
                StationName  = station.StationName,
                TrainLine    = null,
                NumberOnLine = 3254
            };

            _databaseContext.Add(dbStation);
            _databaseContext.SaveChanges();
            return(true);
        }
        public RepositoryModelStation GetStationById(int id)
        {
            if (id == 0)
            {
                return(null);
            }
            var repositoryModelStation = new RepositoryModelStation()
            {
                Id           = id,
                NumberOnLine = 1,
                StationName  = "StasjonsNavn1"
            };

            return(repositoryModelStation);
        }
        public List <RepositoryModelStation> GetAllStations()
        {
            var list = new List <RepositoryModelStation>();
            var repositoryModelStation = new RepositoryModelStation()
            {
                Id           = 1,
                NumberOnLine = 1,
                StationName  = "Lillestrøm"
            };
            var repositoryModelStation2 = new RepositoryModelStation()
            {
                Id           = 1,
                NumberOnLine = 1,
                StationName  = "Oslo S"
            };

            list.Add(repositoryModelStation);
            list.Add(repositoryModelStation2);
            list.Add(repositoryModelStation);
            list.Add(repositoryModelStation2);

            return(list);
        }
        public ActionResult EditStation(AdminModel modelIn)
        {
            var lineIn = _lineBll.GetLineById(modelIn.Line.Id);

            var stationInDb = new DbStation()
            {
                Id           = modelIn.Station.Id,
                StationName  = modelIn.Station.StationName,
                NumberOnLine = modelIn.Station.NumberOnLine,
                TrainLine    = lineIn
            };

            var stationIn = new RepositoryModelStation()
            {
                Id           = modelIn.Station.Id,
                StationName  = modelIn.Station.StationName,
                NumberOnLine = modelIn.Station.NumberOnLine,
                TrainLine    = lineIn
            };

            _stationBll.UpdateStation(stationIn.Id, stationIn);


            for (int i = 0; i < lineIn.Stations.Count; i++)
            {
                if (lineIn.Stations[i].Id == stationInDb.Id)
                {
                    lineIn.Stations[i].StationName  = stationInDb.StationName;
                    lineIn.Stations[i].NumberOnLine = stationInDb.NumberOnLine;
                }
            }
            _lineBll.UpdateLine(lineIn);

            ViewBag.line = lineIn;
            return(View());
        }
 public bool AddStation(RepositoryModelStation station)
 {
     return(true);
 }
 public bool AddStation(RepositoryModelStation station)
 {
     return(_stationRepository.AddStation(station));
 }
 public bool UpdateStation(int id, RepositoryModelStation stationIn)
 {
     return(_stationRepository.UpdateStation(id, stationIn));
 }