static private void LoadData() { if (IsDataLoaded) { return; } List <string[]> rows = new List <string[]>(); using (StreamReader reader = File.OpenText(DATA_FILE)) { while (reader.Peek() >= 0) { string line = reader.ReadLine(); string[] rowArray = CSVRowToStringArray(line); if (rowArray.Length > 0) { rows.Add(rowArray); } } } string[] headers = rows[0]; rows.Remove(headers); AllJobs = new List <Job>(); // Parse each row array foreach (string[] row in rows) { string aName = row[0]; string anEmployer = row[1]; string aLocation = row[2]; string aPositionType = row[3]; string aCoreCompetency = row[4]; Employer newEmployer = (Employer)FindExistingObject(AllEmployers, anEmployer); Location newLocation = (Location)FindExistingObject(AllLocations, aLocation); PositionType newPositionType = (PositionType)FindExistingObject(AllPositionTypes, aPositionType); CoreCompetency newCoreCompetency = (CoreCompetency)FindExistingObject(AllCoreCompetencies, aCoreCompetency); if (newEmployer == null) { newEmployer = new Employer(anEmployer); AllEmployers.Add(newEmployer); } if (newLocation == null) { newLocation = new Location(aLocation); AllLocations.Add(newLocation); } if (newPositionType == null) { newPositionType = new PositionType(aPositionType); AllPositionTypes.Add(newPositionType); } if (newCoreCompetency == null) { newCoreCompetency = new CoreCompetency(aCoreCompetency); AllCoreCompetencies.Add(newCoreCompetency); } Job newJob = new Job(aName, newEmployer, newLocation, newPositionType, newCoreCompetency); AllJobs.Add(newJob); } IsDataLoaded = true; }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { foreach (var JobProperty in jobData.Employers.ToList()) { if (newJobViewModel.EmployerID == JobProperty.ID) { EmployerForJob = JobProperty; } } foreach (var JobProperty in jobData.Locations.ToList()) { if (newJobViewModel.Location == JobProperty.ID) { LocationForJob = JobProperty; } } foreach (var JobProperty in jobData.CoreCompetencies.ToList()) { if (newJobViewModel.CoreCompetency == JobProperty.ID) { CoreCompetencyForJob = JobProperty; } } foreach (var JobProperty in jobData.PositionTypes.ToList()) { if (newJobViewModel.PositionType == JobProperty.ID) { PositionTypeForJob = JobProperty; } } Job newJob = new Job { Name = newJobViewModel.Name, Employer = EmployerForJob, Location = LocationForJob, CoreCompetency = CoreCompetencyForJob, PositionType = PositionTypeForJob, }; jobData.Jobs.Add(newJob); string newUrl = "/Job?id=" + newJob.ID.ToString(); return(Redirect(newUrl)); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { Employer anEmployer = jobData.Employers.Find(newJobViewModel.EmployerID); Location aLocation = jobData.Locations.Find(newJobViewModel.LocationID); CoreCompetency aSkill = jobData.CoreCompetencies.Find(newJobViewModel.SkillId); PositionType aPositionType = jobData.PositionTypes.Find(newJobViewModel.PositionTypeId); Job newjob = new Job { Name = newJobViewModel.Name, Employer = anEmployer, Location = aLocation, CoreCompetency = aSkill, PositionType = aPositionType }; jobData.Jobs.Add(newjob); return(Redirect(String.Format("/Job?id={0}", newjob.ID))); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { if (newJobViewModel != null && newJobViewModel.Name != null) { Employer newEmployer = jobData.Employers.Find(newJobViewModel.EmployerID); Location newLocation = jobData.Locations.Find(newJobViewModel.LocationID); CoreCompetency newCoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID); PositionType newPosition = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID); Job newJob = new Job { Name = newJobViewModel.Name, Employer = newEmployer, Location = newLocation, CoreCompetency = newCoreCompetency, PositionType = newPosition }; jobData.Jobs.Add(newJob); return(Redirect(string.Format("Index/?id={0}", newJob.ID))); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { Location l = jobData.Locations.Find(newJobViewModel.LocationID); Employer e = jobData.Employers.Find(newJobViewModel.EmployerID); CoreCompetency c = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID); PositionType p = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID); Job newJob = new Job { Location = l, Employer = e, CoreCompetency = c, PositionType = p, Name = newJobViewModel.Name }; jobData.Jobs.Add(newJob); return(Redirect(string.Format("/Job?id={0}", newJob.ID))); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6X - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { JobData jobData = JobData.GetInstance(); Employer employer = jobData.Employers.Find(newJobViewModel.EmployerID); Location location = jobData.Locations.Find(newJobViewModel.LocationID); CoreCompetency coreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID); PositionType positionType = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID); Job newJob = new Job { Name = newJobViewModel.Name, Employer = employer, Location = location, CoreCompetency = coreCompetency, PositionType = positionType }; jobData.Jobs.Add(newJob); return(Redirect("/Job?id=" + newJob.ID.ToString())); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { Employer newEmployer = jobData.Employers.ToList().Find(x => x.ID == newJobViewModel.EmployerID); Location newLocation = jobData.Locations.ToList().Find(x => x.ID == newJobViewModel.LocationsID); CoreCompetency newCoreCompetency = jobData.CoreCompetencies.ToList().Find(x => x.ID == newJobViewModel.CoreCompetenciesID); PositionType newPositionType = jobData.PositionTypes.ToList().Find(x => x.ID == newJobViewModel.PositionTypesID); Job brandNewJob = new Job { Name = newJobViewModel.Name, Employer = newEmployer, Location = newLocation, CoreCompetency = newCoreCompetency, PositionType = newPositionType }; jobData.Jobs.Add(brandNewJob); return(Redirect(string.Format("/Job?={0}", brandNewJob.ID))); } return(View(newJobViewModel)); }
public IActionResult New(NewJobViewModel vModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (ModelState.IsValid) { Employer emp = jobData.Employers.Find(vModel.EmployerID); Location loc = jobData.Locations.Find(vModel.LocationID); CoreCompetency corecomp = jobData.CoreCompetencies.Find(vModel.CoreCompetencyID); PositionType pos = jobData.PositionTypes.Find(vModel.PositionID); Job newJob = new Job { Name = vModel.Name, Employer = emp, Location = loc, CoreCompetency = corecomp, PositionType = pos }; jobData.Jobs.Add(newJob); return(Redirect("/Job?id=" + newJob.ID)); } return(View(vModel)); }
public IActionResult New(NewJobViewModel newJobViewModel) { // TODO #6 - Validate the ViewModel and if valid, create a // new Job and add it to the JobData data store. Then // redirect to the Job detail (Index) action/view for the new Job. if (newJobViewModel != null && newJobViewModel.Name != null) { Employer newEmployer = jobData.Employers.Find(newJobViewModel.EmployerID); Location newLocation = jobData.Locations.Find(newJobViewModel.LocationID); CoreCompetency newCoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID); PositionType newPosition = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID); Job newJob = new Job { Name = newJobViewModel.Name, Employer = newEmployer, Location = newLocation, CoreCompetency = newCoreCompetency, PositionType = newPosition }; jobData.Jobs.Add(newJob); return(Redirect(string.Format("Index/?id={0}", newJob.ID))); } return(View(newJobViewModel)); }
public void CreateJobObject() { test_employer = new Employer("ACME"); test_location = new Location("Desert"); test_positionType = new PositionType("Quality control"); test_coreCompentency = new CoreCompetency("Persistence"); test_job1 = new Job("Product tester", test_employer, test_location, test_positionType, test_coreCompentency); test_job2 = new Job("Product tester", test_employer, test_location, test_positionType, test_coreCompentency); }
public void CreateTestJobAndFields() { acme = new Employer("ACME"); desert = new Location("Desert"); qa = new PositionType("Quality Control"); persistence = new CoreCompetency("Persistence"); testJob1 = new Job("Product tester", acme, desert, qa, persistence); }
public Job(string name, Employer employer, Location location, CoreCompetency coreCompetency, PositionType positionType) { Name = name; Employer = employer; Location = location; CoreCompetency = coreCompetency; PositionType = positionType; ID = nextId; nextId++; }
public void TestJobsForEquality() { Employer neighbor = new Employer("neighbor"); Location nextDoor = new Location("nextDoor"); PositionType watching = new PositionType("watching"); CoreCompetency loving = new CoreCompetency("loving"); Job blackCatSitter = new Job("Kitty", neighbor, nextDoor, watching, loving); Job whiteCatSitter = new Job("Kitty", neighbor, nextDoor, watching, loving); Assert.IsFalse(blackCatSitter.Equals(whiteCatSitter)); }
public void TestFieldNotAvailable() { Employer employer = new Employer(); Location location = new Location("Desert"); PositionType positionType = new PositionType("Quality control"); CoreCompetency coreCompetency = new CoreCompetency("Persistence"); Job programmer = new Job("Programmer", employer, location, positionType, coreCompetency); Assert.AreEqual(programmer.ToString(), $"\nID: {programmer.Id}\nName: {programmer.Name}\nEmployer: Data not available\nLocation: {programmer.EmployerLocation}\nPosition Type: {programmer.JobType}\nCore Competency: {programmer.JobCoreCompetency}\n"); }
public void CreateJobs() { job1 = new Job(); job2 = new Job(); emp1 = new Employer("ACME"); loc1 = new Location("Desert"); pos1 = new PositionType("Quality control"); core1 = new CoreCompetency("Persistence"); job3 = new Job("Product tester", emp1, loc1, pos1, core1); job4 = new Job("Product tester", emp1, loc1, pos1, core1); }
public void TestJobsForEquality() { Employer employer = new Employer("ACME"); Location location = new Location("Desert"); PositionType jobType = new PositionType("Quality control"); CoreCompetency jobCoreCompetency = new CoreCompetency("Persistence"); Job job = new Job("Product tester", employer, location, jobType, jobCoreCompetency); Job job2 = new Job("Product tester", employer, location, jobType, jobCoreCompetency); Assert.IsFalse(job.Equals(job2)); }
public void TestJobsForEquality() { Employer marine_corps = new Employer("Marine Corps"); Location virginia = new Location("Virgina"); PositionType sre = new PositionType("SRE"); CoreCompetency data = new CoreCompetency("Data"); Job test_job4 = new Job("Daryn", marine_corps, virginia, sre, data); Job test_job5 = new Job("Daryn", marine_corps, virginia, sre, data); Assert.IsFalse(test_job4.Equals(test_job5)); }
public void TestBlankLinesBeforeAndAfter() { Employer bob = new Employer("bob"); Location house = new Location("house"); PositionType maid = new PositionType("maid"); CoreCompetency fast = new CoreCompetency("fast"); Job cleaner = new Job("Frank", bob, house, maid, fast); string expectedOutput = $"\n ID: {cleaner.Id} \n Name: {cleaner.Name} \n Employer: {cleaner.EmployerName} \n Location: {cleaner.EmployerLocation} \n Position Type: {cleaner.JobType} \n Core Competency: {cleaner.JobCoreCompetency} \n"; Assert.AreEqual(expectedOutput, cleaner.ToString()); }
public void TestJobsForEquality() { Employer testEmployer = new Employer("ACME"); Location testLocation = new Location("Desert"); PositionType testJobType = new PositionType("Quality control"); CoreCompetency testCoreCompetency = new CoreCompetency("Persistence"); Job testJobA = new Job("Product tester", testEmployer, testLocation, testJobType, testCoreCompetency); Job testJobB = new Job("Product tester", testEmployer, testLocation, testJobType, testCoreCompetency); Assert.IsFalse(testJobA.Equals(testJobB)); }
public void TestJobsForEquality() { Employer employer = new Employer("Employer"); Location locationName = new Location("Location"); PositionType position = new PositionType("Location"); CoreCompetency myCompetency = new CoreCompetency("Competency"); Job job1 = new Job("Name", employer, locationName, position, myCompetency); Job job2 = new Job("Name", employer, locationName, position, myCompetency); PositionType position2 = new PositionType("Location"); Assert.IsTrue(position.Equals(position)); }
public void TestToStringReturnsId() { Employer ACME = new Employer("ACME"); Location Desert = new Location("Desert"); PositionType QualityControl = new PositionType("Quality Control"); CoreCompetency Persistence = new CoreCompetency("Persistence"); Job job1 = new Job("Product Tester", ACME, Desert, QualityControl, Persistence); string str = job1.ToString(); Assert.AreEqual("\n" + "Id: " + job1.Id + "\n", str.Substring(0, 7)); Assert.AreEqual("\n" + "Name: " + job1.Name + "\n", str.Substring(6, 22)); }
public void TestJobsForEquality() { Employer employer = new Employer("ACME"); Location location = new Location("Desert"); PositionType positionType = new PositionType("Quality control"); CoreCompetency coreCompetency = new CoreCompetency("Persistence"); Job programmer = new Job("Programmer", employer, location, positionType, coreCompetency); Job developer = new Job("Programmer", employer, location, positionType, coreCompetency); //Job developer = programmer; Assert.IsFalse(programmer.Equals(developer)); }
public IActionResult New(NewJobViewModel newJobViewModel) { if (ModelState.IsValid) { foreach (Employer field in jobData.Employers.ToList()) { if (field.ID == newJobViewModel.EmployerID) { employer = field; } } foreach (Location field in jobData.Locations.ToList()) { if (field.ID == newJobViewModel.LocationID) { location = field; } } foreach (CoreCompetency field in jobData.CoreCompetencies.ToList()) { if (field.ID == newJobViewModel.CoreCompetencyID) { coreCompetency = field; } } foreach (PositionType field in jobData.PositionTypes.ToList()) { if (field.ID == newJobViewModel.PositionTypeID) { positionType = field; } } Job newJob = new Job { Name = newJobViewModel.Name, Employer = employer, Location = location, CoreCompetency = coreCompetency, PositionType = positionType }; jobData.Jobs.Add(newJob); string newUrl = "/Job?id=" + newJob.ID.ToString(); return(Redirect(newUrl)); } return(View(newJobViewModel)); }
public void TestJobToString1() { Employer testEmployer = new Employer("ACME"); Location testLocation = new Location("Desert"); PositionType testJobType = new PositionType("Quality control"); CoreCompetency testCoreCompetency = new CoreCompetency("Persistence"); Job testJob = new Job("Product tester", testEmployer, testLocation, testJobType, testCoreCompetency); string testString = testJob.ToString(); Assert.IsTrue(testString.StartsWith("\n")); Assert.IsTrue(testString.EndsWith("\n")); }
public void TestJobsForEquality() { string name = "Product Tester"; Employer employerName = new Employer("ACME"); Location employerLocation = new Location("Desert"); PositionType jobType = new PositionType("Quality control"); CoreCompetency jobCoreCompetency = new CoreCompetency("Persistence"); Job testJob1 = new Job(name, employerName, employerLocation, jobType, jobCoreCompetency); Job testJob2 = new Job(name, employerName, employerLocation, jobType, jobCoreCompetency); Assert.IsFalse(testJob1.Equals(testJob2)); }
public void TestJobToStringStartsAndEndsWithEmptyLine() { string name = "Product Tester"; Employer employerName = new Employer("ACME"); Location employerLocation = new Location("Desert"); PositionType jobType = new PositionType("Quality control"); CoreCompetency jobCoreCompetency = new CoreCompetency("Persistence"); Job testJob = new Job(name, employerName, employerLocation, jobType, jobCoreCompetency); Assert.IsTrue(testJob.ToString().StartsWith("\n")); Assert.IsTrue(testJob.ToString().EndsWith("\n")); }
public void TestJobConstructorSetsAllFields() { Employer ACME = new Employer("ACME"); Location Desert = new Location("Desert"); PositionType QualityControl = new PositionType("Quality Control"); CoreCompetency Persistence = new CoreCompetency("Persistence"); Job job1 = new Job("Product Tester", ACME, Desert, QualityControl, Persistence); Assert.AreEqual("Product Tester", job1.Name); Assert.AreEqual(Desert.ToString(), job1.EmployerLocation.ToString()); Assert.AreEqual(QualityControl.ToString(), job1.JobType.ToString()); Assert.AreEqual(Persistence.ToString(), job1.JobCoreCompetency.ToString()); }
public void TooStringMethodTestForFieldsandValues() { Employer newEmployer = new Employer("ACME"); Location newLocation = new Location("Desert"); PositionType newPosition = new PositionType("Quality Control"); CoreCompetency coreCompetency = new CoreCompetency("Persistence"); Job newJob1 = new Job("Product Tester", newEmployer, newLocation, newPosition, coreCompetency); string testString = ($"\nID: {newJob1.Id}\nName: {newJob1.Name}\nEmployer: {newJob1.EmployerName}\nLocation: {newJob1.EmployerLocation}\nPosition Type: {newJob1.JobType}\nCore Competency: {newJob1.JobCoreCompetency}\n"); string newJob1String = newJob1.ToString(); Assert.IsTrue(newJob1.ToString().Contains($"\nID: {newJob1.Id}\nName: {newJob1.Name}\nEmployer: {newJob1.EmployerName}\nLocation: {newJob1.EmployerLocation}\nPosition Type: {newJob1.JobType}\nCore Competency: {newJob1.JobCoreCompetency}")); }
public void TestJobsForEquality() { Employer newEmployer = new Employer("ACME"); Location newLocation = new Location("Desert"); PositionType newPosition = new PositionType("Quality Control"); CoreCompetency coreCompetency = new CoreCompetency("Persistence"); Job newJob1 = new Job("Product Tester", newEmployer, newLocation, newPosition, coreCompetency); Job newJob2 = new Job("Product Tester", newEmployer, newLocation, newPosition, coreCompetency); Assert.IsFalse(newJob1.Equals(newJob2)); Assert.IsFalse(newJob2.Equals(newJob1)); }
public void TestConstructorSetsAllFields() { Employer employer = new Employer("ACME"); Location location = new Location("Desert"); PositionType positionType = new PositionType("Quality control"); CoreCompetency coreCompetency = new CoreCompetency("Persistence"); Job productTester = new Job("Product tester", employer, location, positionType, coreCompetency); Assert.IsTrue(productTester.Name == "Product tester" && productTester.EmployerName.ToString() == "ACME" && productTester.JobType.ToString() == "Quality control" && productTester.JobCoreCompetency.ToString() == "Persistence"); }