Ejemplo n.º 1
0
        public Client 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();

            return(new Client(result[0], result[1], result[2], result[3], result[4], result[5], result[6], true));
        }
Ejemplo n.º 2
0
 private void City_Leave(object sender, EventArgs e)
 {
     CorrectTextBox(City, enterCity);
     try
     {
         City.Text = StandartView.ConverteToStandartString(City.Text);
     }
     catch (Exception)
     {
         City.BackColor = Color.Red;
     }
 }
Ejemplo n.º 3
0
 private void FerstName_Leave(object sender, EventArgs e)
 {
     CorrectTextBox(FirstName, enterFirstName);
     try
     {
         FirstName.Text = StandartView.ConverteToStandartString(FirstName.Text);
     }
     catch (Exception)
     {
         FirstName.BackColor = Color.Red;
     }
 }
Ejemplo n.º 4
0
        private bool IsString(TextBox textBox)
        {
            try
            {
                StandartView.ConverteToStandartString(textBox.Text);

                return(true);
            }
            catch (Exception)
            {
                City.BackColor = Color.Red;

                return(false);
            }
        }
Ejemplo n.º 5
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);
        }