VS 2015 automatically generates the following code:
// GET: api/Companies/5 [HttpGet("{id}")] public async Task<IActionResult> GetCompany([FromRoute] int id) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Company company = await _context.Companies.SingleOrDefaultAsync(m => m.Id == id); if (company == null) { return NotFound(); } return Ok(company); }
What is the point of validating ModelState here?
I assume you used the Web Api template. Since you did not start with the "Empty" template, the code generated by VS is what the Microsoft team considered "good practice."
, , , .., . , ( int, , , , ). . .
, .
Source: https://habr.com/ru/post/1667533/More articles:Paragraph segmentation using machine learning - pythonDjango Query set with clear and exclusive together - pythonUsing an unassigned local variable: value type vs custom struct - c #Publicly defined APIDoc definitions - node.jsWPF change DataGridCheckBoxColumn to red dots - checkboxfacebook does not appear on the general image for the first time, although meta has the height and width of the image. - facebookComparing large (~ 40 GB) text data using Pandas or an alternative approach - pythonWPF Custom Style DataGridCheckBoxColumn? - stylesDownload octet stream through jQuery - jqueryJavaFX ScrollPane Scrolling Style - javaAll Articles