Esempio n. 1
0
        public IActionResult AddAdminUser(RegistrationDto model)
        {
            string userId = _httpContextAccessor.HttpContext.User.Claims.FirstOrDefault(
                c => c.Type == ClaimTypes.Name)?.Value;

            if (string.IsNullOrWhiteSpace(userId))
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }

            bool isUserNameExist = _userService.CheckUserNameExist(model.UserName);

            if (isUserNameExist)
            {
                return(BadRequest(new { message = "Please use another user name" }));
            }

            return(Ok(_userService.AddAdminUser(long.Parse(userId), model)));
        }