コード例 #1
0
ファイル: ApiTest.cs プロジェクト: taosunvillanueva/craftdemo
        private async Task <bool> RegisterAsync(RegistrationAPI.Models.Registration userRegistry)
        {
            HttpStatusCode result = HttpStatusCode.BadRequest;

            var json          = JsonConvert.SerializeObject(userRegistry);
            var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

            var response = await client.PostAsync($"Api/RegisterUser", stringContent);

            if (response.IsSuccessStatusCode)
            {
                result = response.StatusCode;
            }

            return(result == HttpStatusCode.Created);
        }
コード例 #2
0
        public static IList <RegistrationAPI.Models.Registration> FetchRandomUserData()
        {
            var result = new List <RegistrationAPI.Models.Registration>();

            for (var i = 0; i < 15; i++)
            {
                var registration = new RegistrationAPI.Models.Registration()
                {
                    Name             = "someperson" + i,
                    Email            = "someperson" + i + "@someperson" + i + ".com",
                    OfficeLocation   = "Boston",
                    SecurityInterest = "Application Security",
                    ShirtSize        = "Mens L"
                };

                result.Add(registration);
            }

            return(result);
        }