コード例 #1
0
 public IActionResult Post([FromBody] Course course)
 {
     if (ModelState.IsValid)
     {
         bool result = repository.AddCourse(course);
         if (result)
         {
             return(Created("AddCourse", course.Id));
         }
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
     return(BadRequest(ModelState));
 }
コード例 #2
0
 public async Task<IActionResult> PostCourse([FromBody] CourseDto course)
 {
     if (ModelState.IsValid)
     {
         bool result = repository.AddCourse(course);
         if (result)
         {
             return Ok("AddCourse");
         }
         return StatusCode(StatusCodes.Status500InternalServerError);
     }
     return BadRequest(ModelState);
 }