Skip to content

Commit

Permalink
Completed TODOs LaunchCode-Education-Archived#1, 2.1, 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
arodrigu12 committed Nov 27, 2019
1 parent a75f584 commit e5b1597
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/TechJobs/Controllers/JobController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using TechJobs.Data;
using TechJobs.Models;
using TechJobs.ViewModels;

namespace TechJobs.Controllers
Expand All @@ -19,8 +20,16 @@ static JobController()
public IActionResult Index(int id)
{
// TODO #1 - get the Job with the given ID and pass it into the view
NewJobViewModel jobViewModel = new NewJobViewModel();
Job job = jobData.Find(id);

return View();
jobViewModel.Name = job.Name;
jobViewModel.Employer = job.Employer;
jobViewModel.Location = job.Location;
jobViewModel.PositionType = job.PositionType;
jobViewModel.CoreCompetency = job.CoreCompetency;

return View(jobViewModel);
}

public IActionResult New()
Expand Down
5 changes: 5 additions & 0 deletions src/TechJobs/ViewModels/NewJobViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class NewJobViewModel
{
[Required]
public string Name { get; set; }
//Added 4 props below for TODO #1
public Employer Employer { get; set; }
public Location Location { get; set; }
public CoreCompetency CoreCompetency { get; set; }
public PositionType PositionType { get; set; }

[Required]
[Display(Name = "Employer")]
Expand Down
32 changes: 27 additions & 5 deletions src/TechJobs/Views/Job/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
@{
// TODO #2.1- declare the ViewModel (outside of this @{ } block)
}
@using TechJobs.ViewModels
@model NewJobViewModel

<table class="job-listing">
@{
// TODO #2.2 - display the job fields, one per row (outside of this @{ } block)
}
</table>
<table class="job-listing">
@{
// TODO #2.2 - display the job fields, one per row (outside of this @{ } block)
}
<tr>
<td>Name</td>
<td>@Model.Name</td>
</tr>
<tr>
<td>Employer</td>
<td>@Model.Employer</td>
</tr>
<tr>
<td>Location</td>
<td>@Model.Location</td>
</tr>
<tr>
<td>Skill</td>
<td>@Model.CoreCompetency</td>
</tr>
<tr>
<td>Position Type</td>
<td>@Model.PositionType</td>
</tr>
</table>

0 comments on commit e5b1597

Please sign in to comment.