Exemple #1
0
        public async Task <IActionResult> Put(long id, [FromBody] CustomerRequestDto customerRequestDto)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (id <= 0)
                {
                    return(BadRequest("Invalid id."));
                }

                await _customerFacade.UpdateAsync(id, customerRequestDto);

                return(NoContent());
            }
            catch (EntityNotFoundException e)
            {
                _logger.LogError(
                    "Exception Details: {message}, {innerException}, {stackTrace}. CorrelationId: {correlationId}",
                    e.Message, e.InnerException?.Message, e.StackTrace,
                    _correlationContext.CorrelationContext.CorrelationId);

                return(NotFound());
            }
            catch (ValidationException e)
            {
                _logger.LogError(
                    "Exception Details: {message}, {innerException}, {stackTrace}. CorrelationId: {correlationId}",
                    e.Message, e.InnerException?.Message, e.StackTrace,
                    _correlationContext.CorrelationContext.CorrelationId);

                return(BadRequest(e.Message));
            }
        }