public async Task <ActionResult <Class> > Post(Class model, CancellationToken cancellationToken) { // add model validation var result = await service.AddClassAsync(model, cancellationToken); return(CreatedAtRoute(new { controller = "classes", id = result.Id }, result)); }
public async Task <IActionResult> CreateClass([FromBody] UpsertClassDto classDto) { if (classDto == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status422UnprocessableEntity)); } var id = await _classesService.AddClassAsync(classDto); return(Ok(id)); }