Esempio n. 1
0
        public static async Task <int> SetupACardReturnId(string description, string title, HttpClient client, string userName)
        {
            var request = new           {
                Url  = $"api/cards/{userName}",
                Body = new
                {
                    Title       = title,
                    Description = description
                }
            };

            var stringContent = ContentHelper.GetStringContent(request.Body);
            var response      = await client.PostAsync(request.Url, stringContent);

            var card = JsonConvert.DeserializeObject <Card>(await response.Content.ReadAsStringAsync());

            return(card.Id);
        }
Esempio n. 2
0
        public static async Task <string> LoginUser(string password, string userName, HttpClient client)
        {
            var loginRequest = new
            {
                Url = "api/auth/login",

                Body = new
                {
                    username = userName,
                    password = password
                }
            };

            var stringContent = ContentHelper.GetStringContent(loginRequest.Body);
            var tokenResponse = await client.PostAsync(loginRequest.Url, stringContent);

            var jsonCompactSerializedString = await tokenResponse.Content.ReadAsStringAsync();

            return(jsonCompactSerializedString);
        }
Esempio n. 3
0
        public static async Task RegisterUser(string password, string userName, HttpClient client)
        {
            var request = new
            {
                Url  = "api/auth/register",
                Body = new
                {
                    username = userName,
                    password = password
                }
            };

            try
            {
                await client.PostAsync(request.Url, ContentHelper.GetStringContent(request.Body));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }