Пример #1
0
        public async Task <IActionResult> PostAsync([FromBody] User user)
        {
            try
            {
                if (user == null)
                {
                    logger.LogInformation($"User is null.  Provide valid user details.");
                    return(BadRequest($"User is null.  Provide valid user details."));
                }

                await manageUser.AddUserAsync(user);

                logger.LogInformation($"User has been added Successfully and the new user id is { user.UserId }");

                return(Ok(user.UserId));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Internal Server error. Try again later"));
            }
        }