public EditLineResultModel PostSaveLine(LineModel data) { var res = new EditLineResultModel(); using (var logic = new LineLogic()) { res.Line = new LineModel( logic.SaveLine( data.Id, data.LineNumber, data.Name, data.Color, data.Direction)); res.Line.Stations = logic.GetStations(res.Line.Id) .OrderBy(z => z.Position) .Select(z => new StationToLineModel(z)) .ToList(); } using (var logic = new StationsLogic()) { res.Stations = logic.GetStationForLine(res.Line.Id) .Select(z => new StationModel(z)) .ToList(); foreach (var station in res.Stations) { station.Students = logic.GetStudents(station.Id) .Select(z => new StudentToLineModel(z)) .ToList(); } } using (var logic = new tblStudentLogic()) { res.Students = logic.GetStudentsForLine(res.Line.Id) .Select(z => new StudentShortInfo(z)) .ToList(); } return(res); }