public static void AddApplicant()
        {
            Applicant        applicant  = new Applicant();
            List <Applicant> applicants = new List <Applicant>();

            applicants = ApplicantService.GetApplicantsFromFile();
            Console.Clear();
            Console.Write("Please enter your first name:\t");
            applicant.FirstName = Console.ReadLine();

            while (!Regex.Match(applicant.FirstName, "^[A-Z][a-zA-Z]*$").Success)
            {
                Console.Write("Please enter a valid name:\t");
                applicant.FirstName = Console.ReadLine();
            }
            Console.Write("\nPlease enter your last name:\t");

            applicant.LastName = Console.ReadLine();

            while (!Regex.Match(applicant.LastName, "^[A-Z][a-zA-Z]*$").Success)
            {
                Console.Write("Please enter a valid name:\t");
                applicant.LastName = Console.ReadLine();
            }

            Console.Write("\nTo be eligible for assistance, your zip code must be in the Louisville Metropolitan Statistical Area.\t");
            Console.WriteLine();
            Console.Write("\nPlease Enter your zip code:  ");
            applicant.ZipCode = Console.ReadLine();

            while (ApplicantService.FindZip(applicant.ZipCode) == null)
            {
                Console.Write("You have entered an ineligible zip code.");
                Console.WriteLine();
                Console.Write("The zip code must be one of the following:");
                Console.WriteLine();
                ApplicantService.ShowZips();
                Console.WriteLine();
                Console.Write("Please enter a zip code from the Louisville MSA:  ");
                applicant.ZipCode = Console.ReadLine();
            }

            ApplicantService.GetPRateFromZip(applicant, applicants);


            ApplicantService.SaveApplicant(applicant, applicants);

            applicants.Add(applicant);

            System.Threading.Thread.Sleep(1000);
        }
        public ActionResult SaveRecord(Applicant applicant)
        {
            if (!string.IsNullOrWhiteSpace(SelectedStateAbbreviation))
            {
                applicant.State = SelectedStateAbbreviation;
            }
            var errors = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();

            if (applicant.Id != 0)
            {
                applicantService.UpdateApplicant(applicant);
            }
            else
            {
                applicantService.SaveApplicant(applicant);
            }
            if (!string.IsNullOrWhiteSpace(_filename))
            {
                applicantService.PostResume(_filename, applicant);
            }
            return(RedirectToAction("Index", "Applicant"));
        }
示例#3
0
        public async Task <IActionResult> Create([FromBody] CreateApplicantDto model)
        {
            try
            {
                var applicantService = new ApplicantService(_unitOfWork);
                var response         = await applicantService.SaveApplicant(model);

                if (!response.Success)
                {
                    _logger.LogInformation($"Bad request on creation of an applicant with email {model.EmailAddress}.");

                    return(BadRequest(response));
                }
                _logger.LogInformation($"Applicant was created successfully with id {response.Data.ID}.");

                return(Created($"http://localhost:5000/api/user/{response.Data.ID}", response));
            }
            catch (Exception e)
            {
                _logger.LogInformation(e.Message);

                return(StatusCode(500, e.Message));
            }
        }