public Response<Application> CreateApplication(Application newApplication)
        {
            var response = new Response<Application>();

            try
            {
                var allApplications = _repo.GetAllApplications();

                int LatestAppNumber = allApplications.Select(a => a.AppID).LastOrDefault();
                newApplication.AppID = LatestAppNumber + 1;

                response.Data = new Application();
                response.Data.FirstName = newApplication.FirstName;
                response.Data.LastName = newApplication.LastName;
                response.Data.Address = newApplication.Address;
                response.Data.PhoneNumber = newApplication.PhoneNumber;
                response.Data.City = newApplication.City;
                response.Data.State = newApplication.State;
                response.Data.Zip = newApplication.Zip;
                response.Data.AppID = newApplication.AppID;
                response.Data.JobHistory = newApplication.JobHistory;

                response.Success = true;
                _repo.CreateApplication(newApplication);
                response.Message = "Application was created.";
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return response;
        }
        public List<Application> GetAllApplications()
        {
            List<Application> applications = new List<Application>();

            var reader = File.ReadAllLines(FilePath);

            for (int i = 1; i < reader.Length; i++)
            {
                var columns = reader[i].Split(',');

                var application = new Application();

                application.FirstName = columns[0];
                application.LastName = columns[1];
                application.AppID = int.Parse(columns[2]);
                application.Address = columns[3];
                application.PhoneNumber = columns[4];
                application.City = columns[5];
                application.State = columns[6];
                application.Zip = columns[7];
                application.JobHistory = columns[8];

                applications.Add(application);
            }

            return applications;
        }
        public void CreateApplication(Application newApplication)
        {
            var applications = GetAllApplications();
            applications.Add(newApplication);

            OverwriteFiles(applications);
        }
Esempio n. 4
0
        public ActionResult EditForm(int id)
        {
            Application application = new Application();
            ApplicantDatabase ad = new ApplicantDatabase();

            application = ad.GetById(id);

            return View(application);
        }
Esempio n. 5
0
        public ActionResult CreateApp2(Application application)
        {
            if (ModelState.IsValid)
            {
                var manager = new ApplicationManager();
                var response = manager.CreateApplication(application);

                return View("CreateApp2", response.Data);
            }
            return View("Create");
        }
Esempio n. 6
0
        public void Add(Application newapplicant)
        {
            if (_applicants.Any())
            {
                newapplicant.applicantId = _applicants.Max(c => c.applicantId) + 1;
            }
            else
            {
                newapplicant.applicantId = 1;
            }

            _applicants.Add(newapplicant);
        }
Esempio n. 7
0
        public ActionResult Index(Application application)
        {
            if (ModelState.IsValid)
            {

                var repo = new ApplicantDatabase();
                repo.Add(application);

                return RedirectToAction("ThankYou");
            }

            return View(application);
        }
Esempio n. 8
0
        public ActionResult EditForm(Application application)
        {
            if (ModelState.IsValid)
            {

                var repo = new ApplicantDatabase();
                repo.Edit(application);

                return RedirectToAction("ViewApplicant");
            }

            return View(application);
        }
Esempio n. 9
0
        public ActionResult Form(Application application)
        {
            if (ModelState.IsValid)
            {

                var repo = new ApplicantDatabase();
                repo.Add(application);

               // string name = application.Name;

                return RedirectToAction("ThankYou", application);
            }

            return View(application);
        }
        public void UpdateApplication(Application applicationToUpdate)
        {
            var applications = GetAllApplications();

            var existingApplication = applications
                .FirstOrDefault(a => a.AppID == applicationToUpdate.AppID);
            existingApplication.FirstName = applicationToUpdate.FirstName;
            existingApplication.LastName = applicationToUpdate.LastName;
            existingApplication.AppID = applicationToUpdate.AppID;
            existingApplication.Address = applicationToUpdate.Address;
            existingApplication.PhoneNumber = applicationToUpdate.PhoneNumber;
            existingApplication.City = applicationToUpdate.City;
            existingApplication.State = applicationToUpdate.State;
            existingApplication.Zip = applicationToUpdate.Zip;
            existingApplication.JobHistory = applicationToUpdate.JobHistory;
        }
Esempio n. 11
0
 public void Edit(Application application)
 {
     _applicants.RemoveAll(c => c.applicantId == application.applicantId);
     _applicants.Add(application);
     _applicants = _applicants.OrderBy(c => c.applicantId).ToList();
 }
Esempio n. 12
0
        // GET: Apply
        public ActionResult Index()
        {
            Application application = new Application();

            return View(application);
        }
Esempio n. 13
0
 public ActionResult ThankYou(Application application)
 {
     return View(application);
 }