@@ -33,6 +33,13 @@ public IActionResult Index()
3333 [ HttpPost ]
3434 public IActionResult Index ( string txtAzurePipelinesYAML , bool chkAddWorkflowDispatch )
3535 {
36+ if ( ! ModelState . IsValid )
37+ {
38+ // If model state is invalid, return to the form with an empty result
39+ ConversionResponse emptyResult = new ConversionResponse ( ) ;
40+ return View ( model : ( emptyResult , chkAddWorkflowDispatch ) ) ;
41+ }
42+
3643 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( txtAzurePipelinesYAML , chkAddWorkflowDispatch ) ;
3744
3845 return View ( model : gitHubResult ) ;
@@ -116,6 +123,11 @@ public IActionResult Index(string txtAzurePipelinesYAML, bool chkAddWorkflowDisp
116123 [ HttpPost ]
117124 public IActionResult DotNetFrameworkDesktopExample ( bool chkAddWorkflowDispatch = false )
118125 {
126+ if ( ! ModelState . IsValid )
127+ {
128+ return RedirectToAction ( nameof ( Index ) ) ;
129+ }
130+
119131 string yaml = Examples . DotNetFrameworkDesktopExample ( ) ;
120132 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
121133 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -125,6 +137,11 @@ public IActionResult DotNetFrameworkDesktopExample(bool chkAddWorkflowDispatch =
125137 [ HttpPost ]
126138 public IActionResult ASPDotNetFrameworkExample ( bool chkAddWorkflowDispatch = false )
127139 {
140+ if ( ! ModelState . IsValid )
141+ {
142+ return RedirectToAction ( nameof ( Index ) ) ;
143+ }
144+
128145 string yaml = Examples . ASPDotNetFrameworkExample ( ) ;
129146 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
130147 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -134,6 +151,11 @@ public IActionResult ASPDotNetFrameworkExample(bool chkAddWorkflowDispatch = fal
134151 [ HttpPost ]
135152 public IActionResult NodeExample ( bool chkAddWorkflowDispatch = false )
136153 {
154+ if ( ! ModelState . IsValid )
155+ {
156+ return RedirectToAction ( nameof ( Index ) ) ;
157+ }
158+
137159 string yaml = Examples . NodeExample ( ) ;
138160 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
139161 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -143,6 +165,11 @@ public IActionResult NodeExample(bool chkAddWorkflowDispatch = false)
143165 [ HttpPost ]
144166 public IActionResult CIExample ( bool chkAddWorkflowDispatch = false )
145167 {
168+ if ( ! ModelState . IsValid )
169+ {
170+ return RedirectToAction ( nameof ( Index ) ) ;
171+ }
172+
146173 string yaml = Examples . CIExample ( ) ;
147174 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
148175 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -152,6 +179,11 @@ public IActionResult CIExample(bool chkAddWorkflowDispatch = false)
152179 [ HttpPost ]
153180 public IActionResult CDExample ( bool chkAddWorkflowDispatch = false )
154181 {
182+ if ( ! ModelState . IsValid )
183+ {
184+ return RedirectToAction ( nameof ( Index ) ) ;
185+ }
186+
155187 string yaml = Examples . CDExample ( ) ;
156188 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
157189 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -161,6 +193,11 @@ public IActionResult CDExample(bool chkAddWorkflowDispatch = false)
161193 [ HttpPost ]
162194 public IActionResult CICDExample ( bool chkAddWorkflowDispatch = false )
163195 {
196+ if ( ! ModelState . IsValid )
197+ {
198+ return RedirectToAction ( nameof ( Index ) ) ;
199+ }
200+
164201 string yaml = Examples . CICDExample ( ) ;
165202 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
166203 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -170,6 +207,11 @@ public IActionResult CICDExample(bool chkAddWorkflowDispatch = false)
170207 [ HttpPost ]
171208 public IActionResult DockerExample ( bool chkAddWorkflowDispatch = false )
172209 {
210+ if ( ! ModelState . IsValid )
211+ {
212+ return RedirectToAction ( nameof ( Index ) ) ;
213+ }
214+
173215 string yaml = Examples . DockerExample ( ) ;
174216 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
175217 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -179,6 +221,11 @@ public IActionResult DockerExample(bool chkAddWorkflowDispatch = false)
179221 [ HttpPost ]
180222 public IActionResult AntExample ( bool chkAddWorkflowDispatch = false )
181223 {
224+ if ( ! ModelState . IsValid )
225+ {
226+ return RedirectToAction ( nameof ( Index ) ) ;
227+ }
228+
182229 string yaml = Examples . AntExample ( ) ;
183230 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
184231 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -188,6 +235,11 @@ public IActionResult AntExample(bool chkAddWorkflowDispatch = false)
188235 [ HttpPost ]
189236 public IActionResult GradleExample ( bool chkAddWorkflowDispatch = false )
190237 {
238+ if ( ! ModelState . IsValid )
239+ {
240+ return RedirectToAction ( nameof ( Index ) ) ;
241+ }
242+
191243 string yaml = Examples . GradleExample ( ) ;
192244 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
193245 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -197,6 +249,11 @@ public IActionResult GradleExample(bool chkAddWorkflowDispatch = false)
197249 [ HttpPost ]
198250 public IActionResult MavenExample ( bool chkAddWorkflowDispatch = false )
199251 {
252+ if ( ! ModelState . IsValid )
253+ {
254+ return RedirectToAction ( nameof ( Index ) ) ;
255+ }
256+
200257 string yaml = Examples . MavenExample ( ) ;
201258 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
202259 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -206,6 +263,11 @@ public IActionResult MavenExample(bool chkAddWorkflowDispatch = false)
206263 [ HttpPost ]
207264 public IActionResult PythonExample ( bool chkAddWorkflowDispatch = false )
208265 {
266+ if ( ! ModelState . IsValid )
267+ {
268+ return RedirectToAction ( nameof ( Index ) ) ;
269+ }
270+
209271 string yaml = Examples . PythonExample ( ) ;
210272 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
211273 return View ( viewName : "Index" , model : gitHubResult ) ;
@@ -215,6 +277,11 @@ public IActionResult PythonExample(bool chkAddWorkflowDispatch = false)
215277 [ HttpPost ]
216278 public IActionResult RubyExample ( bool chkAddWorkflowDispatch = false )
217279 {
280+ if ( ! ModelState . IsValid )
281+ {
282+ return RedirectToAction ( nameof ( Index ) ) ;
283+ }
284+
218285 string yaml = Examples . RubyExample ( ) ;
219286 ( ConversionResponse , bool ) gitHubResult = ProcessConversion ( yaml , chkAddWorkflowDispatch ) ;
220287 return View ( viewName : "Index" , model : gitHubResult ) ;
0 commit comments