예제 #1
0
        public async Task <IActionResult> Post([FromBody] StudyNoIdDTO study)
        {
            if (!ModelState.IsValid)
            {
                _log.LogWarning("ModelState not valid. Return BadRequest");
                return(BadRequest(ModelState));
            }

            var id = await _repository.CreateAsync(study);

            return(CreatedAtAction(nameof(Get), new { id }, null));
        }
예제 #2
0
        public async Task <IActionResult> Post([FromBody] StudyDTO study)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var id = await _repository.CreateAsync(study);

            study.Id = id;

            return(CreatedAtAction("Get", new { id }, study));
        }