コード例 #1
0
        public async Task <IActionResult> UpdatePositionAsync([FromRoute][Required] int id, [FromBody] ZooAnimalRegisterDto obj)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(new ResponseErrorDto((int)HttpStatusCode.BadRequest, "Review Required Parameters")));
                }
                var updated = await _animalService.UpdateAnimalAsync(id, obj, User.GetIdUser());

                return(Ok(new ResponseDto <ZooAnimalRegisterDto>((int)HttpStatusCode.OK, "Ok", obj)));
            }
            catch (ExceptionDto exdto)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new ResponseErrorDto((int)HttpStatusCode.InternalServerError, exdto.UserMessage, exdto.Id)));
            }
            catch (Exception ex)
            {
                var guid = Guid.NewGuid();
                _logger.Log(LogLevel.Error, ex, guid.ToString());
                return(BadRequest(new ResponseErrorDto((int)HttpStatusCode.BadRequest, "Failed to create the animal information.", guid)));
            }
        }
コード例 #2
0
        public async Task <IActionResult> UpdateAnimal(Guid animalId, [FromBody] AnimalCreate animal)
        {
            await _animalManager.UpdateAnimalAsync(animalId, animal);

            return(Ok());
        }