public async Task <IActionResult> CreateAsync([FromBody] ApplicantDetails applicantDetails)
        {
            Boolean valid   = false;
            var     country = await RESTCountriesAPI.GetCountryByFullNameAsync(applicantDetails.CountryOfOrigin);

            logger.LogInformation(country.Name);
            if (country.Name.ToUpper() == applicantDetails.CountryOfOrigin.ToUpper())
            {
                valid = true;
            }

            if (valid)
            {
                logger.LogInformation("New applicant is added.");
                await _repository.AddApplicantDetailsAsync(applicantDetails);

                logger.LogInformation(nameof(GetById), new { id = applicantDetails.ID }, applicantDetails);
                return(CreatedAtAction(nameof(GetById), new { id = applicantDetails.ID }, applicantDetails));
            }
            else
            {
                logger.LogInformation($"{applicantDetails.CountryOfOrigin} is not a valid country");
                return(BadRequest());
            }
        }
Exemplo n.º 2
0
        async void requestRest(string userNameCountry)
        {
            Country restCountry = await RESTCountriesAPI.GetCountryByFullNameAsync(userNameCountry);

            CountryTextBox.Text = ($"Название: {restCountry.Name}\n" +
                                   $"Код: {restCountry.Alpha2Code}\n" +
                                   $"Площадь: {restCountry.Area}\n" +
                                   $"Население: {restCountry.Population}\n" +
                                   $"Столица: {restCountry.Capital}\n" +
                                   $"Регион: {restCountry.Region}");
            DialogResult result = MessageBox.Show(
                "Сохранить страну в базу?",
                "Сохранение",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Information,
                MessageBoxDefaultButton.Button1,
                MessageBoxOptions.DefaultDesktopOnly);

            if (result == DialogResult.Yes)
            {
                WriteinDB(restCountry);
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Search(string countryName)
        {
            var c = await RESTCountriesAPI.GetCountryByFullNameAsync(countryName);

            return(View(c));
        }