public async Task <IActionResult> Put([FromBody] UpdateApplicant updateApplicant)
        {
            var applicant = await applicantBiz.UpdateApplicant(updateApplicant);

            var result = Json(applicant);

            result.StatusCode = (int)HttpStatusCode.OK;
            return(result);
        }
Beispiel #2
0
 public ActionResult UpdateButton(Applicant app)
 {
     if (app.Appstatus == "new")
     {
         UpdateApplicant objreg = new UpdateApplicant();
         objreg.UpdateRecords(app);
         return(View(app));
     }
     else
     {
         ViewBag.Appstatus = app.Appstatus;
         return(View(app));
     }
 }
Beispiel #3
0
        public async Task <Applicant> UpdateApplicant(UpdateApplicant updateApplicant)
        {
            _Logger.LogInformation($"Updating the applicant whose Name:- {updateApplicant.FamilyName} {updateApplicant.Name}");

            //Fetch the applicant Details
            Applicant applicantDetails = await repository.GetApplicant(updateApplicant.ID);

            bool isValidCountryOfOrigin = true;

            if (applicantDetails != null)
            {
                _Logger.LogInformation($"Applicant existing in the Database");
                if (applicantDetails.CountryOfOrigin != updateApplicant.CountryOfOrigin)
                {
                    _Logger.LogInformation($"Validating the Country if the Update Model has a different country than the Existing");
                    isValidCountryOfOrigin = await integrationService.IsCountryExist(updateApplicant.CountryOfOrigin);
                }

                if (isValidCountryOfOrigin)
                {
                    _Logger.LogInformation($"Country is Valid");
                    applicantDetails           = mapper.Map <Applicant>(updateApplicant);
                    applicantDetails.UpdatedAt = DateTime.Now;
                    var applicantfromDB = await repository.UpdateApplicant(applicantDetails);

                    _Logger.LogDebug($"Updated Applicant Information {JsonConvert.SerializeObject(applicantDetails)}");
                    return(applicantfromDB);
                }
                else
                {
                    _Logger.LogError($"{updateApplicant.CountryOfOrigin} is Invalid. Please check the CountryOfOrigin again", updateApplicant.CountryOfOrigin.GetType().Name);
                    throw new ArgumentException($"{updateApplicant.CountryOfOrigin} is Invalid. Please check the CountryOfOrigin again", updateApplicant.CountryOfOrigin.GetType().Name);
                }
            }
            else
            {
                _Logger.LogError($"No Applicant Exists with the Id {updateApplicant.ID}");
                throw new ArgumentException($"No Applicant Exists with the Id {updateApplicant.ID}");
            }
        }