public async Task <IActionResult> Create([FromBody] ApplicantUi applicantUi, CancellationToken token)
        {
            _logger.LogInformation("Create applicant called with {0} : {1}", nameof(applicantUi), JsonConvert.SerializeObject(applicantUi));

            if (!ModelState.IsValid)
            {
                _logger.LogError("Applicant's object not valid: {0}", JsonConvert.SerializeObject(ModelState));

                return(BadRequest(ModelState));
            }

            //validate country
            var validationResult = await _countryService.Validate(applicantUi.CountryOfOrigin, token);

            if (!validationResult)
            {
                _logger.LogError("Country of origin is not valid");
                return(BadRequest("Country of origin is not valid"));
            }


            var applicant = _mapper.Map <ApplicantUi, Applicant>(applicantUi);
            var result    = await _applicantService.Create(applicant, token);

            if (result.IsSuccessful)
            {
                _logger.LogInformation("Create applicant successful");
                applicantUi.ID = result.Result.ID;
                return(Created($"/api/applicants/get/{applicant.ID}", applicantUi));
            }

            return(BadRequest(result.Message));
        }
        public async Task <IActionResult> Update([FromBody] ApplicantUi applicantUi, CancellationToken token)
        {
            _logger.LogInformation("Update applicant called with {0} : {1}", nameof(applicantUi), JsonConvert.SerializeObject(applicantUi));

            if (!ModelState.IsValid)
            {
                _logger.LogInformation("Update applicant called failed with {0} : {1}", nameof(ModelState), JsonConvert.SerializeObject(ModelState));
                return(BadRequest(ModelState));
            }

            var countryValidationResult = await _countryService.Validate(applicantUi.CountryOfOrigin, token);

            if (!countryValidationResult)
            {
                _logger.LogError("Country of origin is not valid");
                return(BadRequest("Country of origin is not valid"));
            }


            if (applicantUi.ID <= 0)
            {
                _logger.LogError("Invalid applicant's id");
                return(BadRequest("Invalid applicant's id"));
            }


            var applicant = _mapper.Map <ApplicantUi, Applicant>(applicantUi);

            var result = await _applicantService.Update(applicant, token);

            if (!result.IsSuccessful)
            {
                _logger.LogError(result.Message);
                return(BadRequest(result.Message));
            }

            _logger.LogInformation(result.Message);
            return(Ok(applicantUi));
        }