Exemplo n.º 1
0
        public async Task <IActionResult> PutAsync(int id, [FromBody] User user)
        {
            try
            {
                logger.LogInformation($"Updating user {id}");
                if (user == null || id != user.UserId)
                {
                    logger.LogInformation("Invalid user to edit");
                    return(BadRequest("Invalid user to edit."));
                }

                await manageUser.EditUserAsync(id, user);

                logger.LogInformation($"User has been updated successfully for the user id { user.UserId } ");
                return(Ok(user.UserId));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Internal Server error. Try again later"));
            }
        }