public List<Applicant> GetAll() { var reader = File.ReadAllLines(_filepath); var list = new List<Applicant>(); for (int i = 0; i < reader.Length; i++) { if (reader.Length > 0) { var columns = reader[i].Split('^'); var applicant = new Applicant(); applicant.Name = columns[0]; applicant.Email = columns[1]; applicant.Phone = columns[2]; applicant.Address = columns[3]; applicant.City = columns[4]; applicant.State= columns[5]; applicant.Zip = columns[6]; applicant.Experience = columns[7]; applicant.Education = columns[8]; applicant.ApplicantId = Int32.Parse(columns[9]); list.Add(applicant); } } return list; }
// Draws appliction form public ActionResult DrawApplication() { var applicant = new Applicant(); var repo = new StatesDatabase(); var states = new List<States>(); states = repo.GetAll(); applicant.StateList = new SelectList(states, "StateName", "Abbreviation"); return View(applicant); }
public ViewResult ApplyNow(Applicant newApp) { if (ModelState.IsValid) { var repo = new ApplicantDatabase(); repo.Add(newApp); return View("ThanksForApplying", newApp); } return View("DrawApplication"); }
public void Add(Applicant newApplicant) { var applicants = GetAll(); if (applicants.Any()) { newApplicant.ApplicantId = applicants.Max(c => c.ApplicantId) + 1; } else { newApplicant.ApplicantId = 1; } applicants.Add(newApplicant); using (var writer = File.CreateText(_filepath)) { foreach (var a in applicants) { writer.WriteLine("{0}^{1}^{2}^{3}^{4}^{5}^{6}^{7}^{8}^{9}", a.Name, a.Email, a.Phone, a.Address, a.City, a.State, a.Zip, a.Experience, a.Education, a.ApplicantId); } } }