Ejemplo n.º 1
0
        public async Task <IActionResult> Put(int id, [FromBody] StudyDTO study)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var ok = await _repository.UpdateAsync(study);

            if (ok)
            {
                return(NoContent());
            }

            return(NotFound());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Put(int id, [FromBody] StudyDTO study)
        {
            if (id != study.Id)
            {
                _log.LogWarning("id={id} does not match study.Id={study.Id}.", id, study.Id);
                ModelState.AddModelError(string.Empty, "id is not matching study.Id");
            }
            if (!ModelState.IsValid)
            {
                _log.LogWarning("ModelState not valid. Return BadRequest");
                return(BadRequest(ModelState));
            }

            var wasUpdated = await _repository.UpdateAsync(study);

            if (!wasUpdated)
            {
                _log.LogDebug("study={study} not found. Return 404 NotFound", study);
                return(NotFound());
            }

            return(NoContent());
        }