Пример #1
0
        public IActionResult PostNew([FromBody] string username)
        {
            if (username != "")
            {
                try
                {
                    var apiKey = UserDatabaseAccess.UserAdd(_context, username);

                    if (apiKey == null)
                    {
                        return(StatusCode(403, "Oops. This username is already in use. Please try again with a new username."));
                    }
                    else
                    {
                        return(StatusCode(200, apiKey));
                    }
                }
                catch
                {
                    return(StatusCode(400, "Oops. Make sure your body contains a string with your username and your Content - Type is Content - Type:application / json"));
                }
            }
            return(StatusCode(400, "Oops. Make sure your body contains a string with your username and your Content - Type is Content - Type:application / json"));
        }