// Display the search form public IActionResult Index() { SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); jobsViewModel.Title = "Search"; return(View(jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { /*ViewBag.columns = ListController.columnChoices; * List<Dictionary<string, string>> jobs = new List<Dictionary<string, string>>(); * if (string.IsNullOrEmpty(searchTerm)) * { * jobs = JobData.FindAll(); * ViewBag.jobs = jobs; * return View("Index"); * * } */ if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
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) { Models.Job newJob = new Models.Job() { Name = newJobViewModel.Name, Employer = jobData.Employers.Find(newJobViewModel.EmployerID), Location = jobData.Locations.Find(newJobViewModel.LocationID), CoreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID), PositionType = jobData.PositionTypes.Find(newJobViewModel.PositionID), }; jobData.Jobs.Add(newJob); SearchJobsViewModel jobById = new SearchJobsViewModel(); jobById.Jobs = new List <Job>(); jobById.Jobs.Add(newJob); return(View("Index", jobById)); } else { return(View(newJobViewModel)); } }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (ModelState.IsValid) { if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.Jobs; } else if (jobsViewModel.Column.Equals(JobFieldType.All)) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view if (id != 99999) { job = jobData.Find(id); } List <Job> jobList = new List <Job>(); jobList.Add(job); SearchJobsViewModel jobViewModel = new SearchJobsViewModel(); jobViewModel.Jobs = jobList; jobViewModel.Title = "Specific Job"; jobData.Jobs.Add(job); return(View(jobViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (jobsViewModel.Value == null) //if (jobsViewModel.Value == null && jobsViewModel.Column.Equals(JobFieldType.All)) { jobsViewModel.Jobs = jobData.Jobs; } //else if (jobsViewModel.Column != JobFieldType.All && jobsViewModel.Value != null) //{ //return Redirect(Views/List/Index.cshtml); //} else if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { ViewBag.message = ""; if (!string.IsNullOrEmpty(jobsViewModel.Value)) { if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; } else if (jobsViewModel.Column.Equals(JobFieldType.All) && string.IsNullOrEmpty(jobsViewModel.Value)) { jobsViewModel.Title = "All Jobs Results"; jobsViewModel.Jobs = jobData.Jobs; } else if (!jobsViewModel.Column.Equals(JobFieldType.All) && string.IsNullOrEmpty(jobsViewModel.Value)) { jobsViewModel.Title = "Search"; ViewBag.message = "Empty search term!";// Do not accept empty search term. } return(View("Index", jobsViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); jobsViewModel.Jobs = jobData.Find(id); return(View("Index", jobsViewModel)); }
public IActionResult New() { NewJobViewModel newJobViewModel = new NewJobViewModel(); SearchJobsViewModel jobsByIdViewModel = new SearchJobsViewModel(); jobsByIdViewModel.Jobs = jobData.Jobs; return(View(newJobViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); jobsViewModel.job = jobData.Find(id); jobsViewModel.Title = "job(s) for:"; return(View(jobsViewModel)); }
// Lists Jobs with a given field matching a given value public IActionResult Jobs(JobFieldType column, string value) { SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); jobsViewModel.Jobs = jobData.FindByColumnAndValue(column, value); jobsViewModel.Title = "Jobs with " + column + ": " + value; return(View(jobsViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel jobById = new SearchJobsViewModel(); jobById.Jobs = new List <Job>(); jobById.Jobs.Add(jobData.Find(id)); //Models.Job jobById = jobData.Find(id); return(View(jobById)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { jobsViewModel.Jobs = jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("") ? jobData.FindByValue(jobsViewModel.Value) : jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel searchJobsViewModel = new SearchJobsViewModel(); //Job newJob = new Job(); Job newJob = jobData.Find(id); searchJobsViewModel.Jobs = new System.Collections.Generic.List <Job>(); searchJobsViewModel.Jobs.Add(newJob); return(View(searchJobsViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel model = new SearchJobsViewModel(); model.Jobs = new List <Job> { jobData.Find(id) }; return(View(model)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { SearchJobsViewModel singleJobViewModel = new SearchJobsViewModel(); if (id == 0) { singleJobViewModel.Title = "No job selected"; return(View(singleJobViewModel)); } // TODO #1 - get the Job with the given ID and pass it into the view singleJobViewModel.SingleJob = jobData.Find(id); singleJobViewModel.Title = "Job Details"; return(View(singleJobViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) {// add validation for empty string if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (jobsViewModel.Column.Equals(JobFieldType.All) || /*jobsViewModel.Value.Equals("")*/ String.IsNullOrEmpty(value)) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
public IActionResult Index(int id) { SearchJobsViewModel jobsViewModel = new SearchJobsViewModel { Jobs = jobData.Jobs }; foreach (var i in jobsViewModel.Jobs) { if (i.ID == id) { return(View(i)); } } return(Redirect("/Job?id=1")); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view] SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); TechJobs.Models.Job jobInfo = new TechJobs.Models.Job(); //Unclear if this is necessary. jobInfo = jobData.Find(id); jobsViewModel.Jobs = new List(); //Initialize the Jobs list. This appears to solve the null issue. jobsViewModel.Jobs.Add(jobInfo); //System.NullReferenceException: 'Object reference not set to an instance of an object.' //TechJobs.ViewModels.SearchJobsViewModel.Jobs.get returned null. jobsViewModel.Title = "Job"; return(View(jobsViewModel)); }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - get the Job with the given ID and pass it into the view SearchJobsViewModel jobsViewModel = new SearchJobsViewModel { Jobs = jobData.Jobs }; foreach (var i in jobsViewModel.Jobs) { if (i.ID == id) { return(View(i)); } } return(Redirect("/Job?=1")); }
// Lists the values of a given column, or all jobs if selected public IActionResult Values(JobFieldType column) { if (column.Equals(JobFieldType.All)) { SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); jobsViewModel.Jobs = jobData.Jobs; jobsViewModel.Title = "All Jobs"; return(View("Jobs", jobsViewModel)); } else { JobFieldsViewModel jobFieldsViewModel = new JobFieldsViewModel(); IEnumerable <JobField> fields; //this is an instance of a list called fields, its data type is JobField //it will hold the jobs found from the search switch (column) { //switch cases that take a column type and adds all jobs in jobdata that match to a list //while converting it to a jobfield object case JobFieldType.Employer: fields = jobData.Employers.ToList().Cast <JobField>(); break; case JobFieldType.Location: fields = jobData.Locations.ToList().Cast <JobField>(); break; case JobFieldType.CoreCompetency: fields = jobData.CoreCompetencies.ToList().Cast <JobField>(); break; case JobFieldType.PositionType: default: fields = jobData.PositionTypes.ToList().Cast <JobField>(); break; } jobFieldsViewModel.Fields = fields; //view model that will take all the jobs found and pass it to view jobFieldsViewModel.Title = "All " + column + " Values"; jobFieldsViewModel.Column = column; return(View(jobFieldsViewModel)); } }
// The detail display for a given Job at URLs like /Job?id=17 public IActionResult Index(int id) { // TODO #1 - Completted // get the Job with the given ID and pass it into the view SearchJobsViewModel jobsByIdViewModel = new SearchJobsViewModel(); //JobFieldData<Employer> jobFieldData = new JobFieldData<Employer>() ; //Job jobById= jobData.Find(id); //jobsByIdViewModel.Jobs[0] = jobFieldData.Find(id); jobsByIdViewModel.Jobs = new List <Job>(); // Kit recommended instantiating the .Jobs so I can pass in the .Find jobsByIdViewModel.Jobs.Add(jobData.Find(id)); // Kit recommended .Add //Console.WriteLine(jobsByIdViewModel.Jobs[0]); //Console.ReadLine(); jobsByIdViewModel.Title = "Job #" + id; return(View(jobsByIdViewModel)); }
// Lists the values of a given column, or all jobs if selected public IActionResult Values(JobFieldType column) { if (column.Equals(JobFieldType.All)) { SearchJobsViewModel jobsViewModel = new SearchJobsViewModel { Jobs = jobData.Jobs, Title = "All Jobs" }; return(View("Jobs", jobsViewModel)); } else { JobFieldsViewModel jobFieldsViewModel = new JobFieldsViewModel(); IEnumerable <JobField> fields; switch (column) { case JobFieldType.Employer: fields = jobData.Employers.ToList().Cast <JobField>(); break; case JobFieldType.Location: fields = jobData.Locations.ToList().Cast <JobField>(); break; case JobFieldType.CoreCompetency: fields = jobData.CoreCompetencies.ToList().Cast <JobField>(); break; case JobFieldType.PositionType: default: fields = jobData.PositionTypes.ToList().Cast <JobField>(); break; } jobFieldsViewModel.Fields = fields; jobFieldsViewModel.Title = "All " + column + " Values"; jobFieldsViewModel.Column = column; return(View(jobFieldsViewModel)); } }
public IActionResult New(NewJobViewModel newJobViewModel) { JobData jobData = JobData.GetInstance(); Employer employer = new Employer(); employer = jobData.Employers.Find(newJobViewModel.EmployerID); Location location = new Location(); location = jobData.Locations.Find(newJobViewModel.LocationID); CoreCompetency coreCompetency = new CoreCompetency(); coreCompetency = jobData.CoreCompetencies.Find(newJobViewModel.CoreCompetencyID); PositionType positionType = new PositionType(); positionType = jobData.PositionTypes.Find(newJobViewModel.PositionTypeID); Job newJob = new Job(); newJob.Name = newJobViewModel.Name; newJob.Employer = employer; newJob.Location = location; newJob.CoreCompetency = coreCompetency; newJob.PositionType = positionType; if (newJob.Name != null) { jobData.Jobs.Add(newJob); SearchJobsViewModel jobsViewModel = new SearchJobsViewModel(); //jobsViewModel.job = newJob; //jobsViewModel.Title = "job for:" ; int id = newJob.ID; return(Redirect("/job?id=" + id)); //return View("Index", jobsViewModel); } return(View(newJobViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (string.IsNullOrEmpty(jobsViewModel.Value)) { return(Redirect("/search/index?tryagain")); } if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (ModelState.IsValid)// Added by AR to force user to enter a search term { if (jobsViewModel.Column.Equals(JobFieldType.All) /*|| jobsViewModel.Value.Equals("")*/) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; //return View("Index", jobsViewModel); } return(View("Index", jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { //fix blank search issue... if (string.IsNullOrEmpty(jobsViewModel.Value)) { return(Redirect("/Search/Index")); } //end fix if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); } jobsViewModel.Title = "Search"; return(View("Index", jobsViewModel)); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (jobsViewModel.Column.Equals(JobFieldType.All) || jobsViewModel.Value.Equals("")) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); jobsViewModel.Message = "Jobs with " + jobsViewModel.Value; } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); jobsViewModel.Message = "Jobs with " + jobsViewModel.Column + ": " + jobsViewModel.Value; } jobsViewModel.Title = "Search"; return View("Index", jobsViewModel); }
// Process search submission and display search results public IActionResult Results(SearchJobsViewModel jobsViewModel) { if (jobsViewModel.Value == null) { jobsViewModel.Title = "keyword can't empty,please try again"; } else if (jobsViewModel.Column.Equals(JobFieldType.All)) { jobsViewModel.Jobs = jobData.FindByValue(jobsViewModel.Value); jobsViewModel.Title = "Search"; } else { jobsViewModel.Jobs = jobData.FindByColumnAndValue(jobsViewModel.Column, jobsViewModel.Value); jobsViewModel.Title = "Search"; } return(View("Index", jobsViewModel)); }