public string[] GenerateСlient(string city = null)
        {
            var responseMessage = _httpClient.GetAsync("https://randomuser.me/api/?inc=gender,name,location,login,dob,nat=gb&noinfo").Result;

            var contentString = responseMessage.Content.ReadAsStringAsync().Result;

            // я так и не понял почему я не могу обойтись без листа
            var a = JsonSerializer.Deserialize <Root>(contentString).results.First();

            var result = new string[7];

            result[0] = a.login.username;

            result[1] = a.login.password;

            result[2] = a.name.last + ' ' + a.name.first;

            result[3] = a.gender;

            result[4] = a.dob.date.ToShortDateString();

            // не смог использовать ??  кишки тонки
            result[5] = (city == null) ? a.location.city : StandartView.ConverteToStandartString(city);

            result[6] = GeneratePhoneNumber();

            Dispose();

            return(result);
        }
Beispiel #2
0
        public Client(string login, string password, string myFulName, string sex, string myBirthday,
                      string myCity, string myPhoneNumber, bool isStandartView = false) : base(login, password, isStandartView)
        {
            MyFulName = new FulName(myFulName, isStandartView);

            MyBirthday = StandartView.ConverteStringToDate(myBirthday);

            MyCity = (isStandartView) ? myCity : StandartView.ConverteToStandartString(myCity);

            MyPhoneNumber = (isStandartView) ? myPhoneNumber : StandartView.ConverteToStandartPhoneNumber(myPhoneNumber);

            MySex = new Gender(sex);

            MyZodiacSign = new ZodiacSign(MyBirthday);

            MyCompatibilityByName = new СompatibilityByName(MyFulName.FirstName);
        }