@@ -102,7 +102,6 @@ public async Task<IActionResult> EditAlbum(int albumCode, bool isAdmin = false)
102102 [ HttpPost ]
103103 public async Task < IActionResult > SaveAlbum ( int albumCode , string txtArtist , string txtAlbumName , string txtYear ,
104104 bool chkIsBassTab , bool chkIncludeInIndex , bool chkIncludeOnWebsite , bool chkIsMiscCollectionAlbum , bool isAdmin = false )
105- //string txtTrackList)
106105 {
107106
108107 if ( ! int . TryParse ( txtYear , out int year ) )
@@ -116,7 +115,7 @@ public async Task<IActionResult> SaveAlbum(int albumCode, string txtArtist, stri
116115 AlbumCode = albumCode ,
117116 ArtistName = txtArtist ,
118117 AlbumName = txtAlbumName ,
119- AlbumYear = int . Parse ( txtYear ) ,
118+ AlbumYear = year ,
120119 IsBassTab = chkIsBassTab ,
121120 IncludeInIndex = chkIncludeInIndex ,
122121 IncludeOnWebsite = chkIncludeOnWebsite ,
@@ -165,15 +164,25 @@ public async Task<IActionResult> EditTab(int tabCode, bool isAdmin = false)
165164 [ HttpPost ]
166165 public async Task < IActionResult > SaveTab ( int tabCode , int albumCode , string txtTabName , string txtTabText , string txtOrder , string cboRating , string cboTuning , bool isAdmin = false )
167166 {
167+ // Safely parse numeric values from the request, falling back to 0 on invalid input
168+ int tabOrder = 0 ;
169+ int . TryParse ( txtOrder , out tabOrder ) ;
170+
171+ int rating = 0 ; // 0 = no rating, consistent with AddNewTrack
172+ int . TryParse ( cboRating , out rating ) ;
173+
174+ int tuningCode = 0 ; // 0 = no tuning, consistent with AddNewTrack
175+ int . TryParse ( cboTuning , out tuningCode ) ;
176+
168177 Tab tab = new ( )
169178 {
170179 TabCode = tabCode ,
171180 AlbumCode = albumCode ,
172181 TabName = txtTabName ,
173182 TabText = txtTabText ,
174- TabOrder = int . Parse ( txtOrder ) ,
175- Rating = int . Parse ( cboRating ) ,
176- TuningCode = int . Parse ( cboTuning )
183+ TabOrder = tabOrder ,
184+ Rating = rating ,
185+ TuningCode = tuningCode
177186 } ;
178187 await _ServiceApiClient . SaveTab ( tab ) ;
179188
0 commit comments