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()); }