Ejemplo n.º 1
0
        public static async Task <bool> SignUpAsync(UserSignUp userSignUp, HttpClient client)
        {
            HttpResponseMessage response = await client.PostAsJsonAsync(
                "api/signup", userSignUp);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static async Task <bool> SignUp(string username, string name, string password, string email)
        {
            var client = new HttpClient();

            SetupClientDefaults(client);
            client.BaseAddress = new Uri(baseAddress);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            try
            {
                Random     random     = new Random();
                int        start      = random.Next(0, avatar.Length);
                string     getavatar  = avatar[start];
                UserSignUp userSignUp = new UserSignUp
                {
                    username = username,
                    name     = name,
                    password = password,
                    email    = email,
                    avatar   = getavatar,
                };
                bool check = await SignUpAsync(userSignUp, client);

                if (check)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
            finally
            {
            }
        }