Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 5 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions TechJobsPersistentAutograded.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.810.23
# Visual Studio Version 17
VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechJobsPersistentAutograded", "TechJobsPersistentAutograded\TechJobsPersistentAutograded.csproj", "{7FBBE2AA-25E6-405E-8E0E-E4321B77887A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TechJobsPersistentAutograded", "TechJobsPersistentAutograded\TechJobsPersistentAutograded.csproj", "{7FBBE2AA-25E6-405E-8E0E-E4321B77887A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskTwo.Tests", "TechJobsPersistent.Tests\TaskTwo.Tests.csproj", "{88B229FD-1BAB-43D8-9F94-0BF2ED3BAD47}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskTwo.Tests", "TechJobsPersistent.Tests\TaskTwo.Tests.csproj", "{88B229FD-1BAB-43D8-9F94-0BF2ED3BAD47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskOne.Tests", "AutogradingTests\TaskOne.Tests.csproj", "{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskOne.Tests", "AutogradingTests\TaskOne.Tests.csproj", "{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskThree.Tests", "TaskThree.Tests\TaskThree.Tests.csproj", "{4976B10E-1E87-4462-9A76-6E86FE278BE4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskThree.Tests", "TaskThree.Tests\TaskThree.Tests.csproj", "{4976B10E-1E87-4462-9A76-6E86FE278BE4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +27,8 @@ Global
{88B229FD-1BAB-43D8-9F94-0BF2ED3BAD47}.Release|Any CPU.Build.0 = Release|Any CPU
{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DFEF4E6-2CB8-41F0-B934-04A49ADA0DFE}.Release|Any CPU.Build.0 = Release|Any CPU
{4976B10E-1E87-4462-9A76-6E86FE278BE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4976B10E-1E87-4462-9A76-6E86FE278BE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4976B10E-1E87-4462-9A76-6E86FE278BE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
45 changes: 40 additions & 5 deletions TechJobsPersistentAutograded/Controllers/EmployerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using TechJobsPersistentAutograded.Data;
using TechJobsPersistentAutograded.Models;
using TechJobsPersistentAutograded.ViewModels;
Expand All @@ -14,25 +15,59 @@ namespace TechJobsPersistentAutograded.Controllers
public class EmployerController : Controller
{

private JobRepository _repo;


public EmployerController(JobRepository repo)
{
_repo = repo;
}


// GET: /<controller>/
public IActionResult Index()
{
return View();
IEnumerable<Employer> employers = _repo.GetAllEmployers();

return View(employers);
}

public IActionResult Add()
{
return View();
AddEmployerViewModel viewModel = new AddEmployerViewModel();

return View(viewModel);
}

public IActionResult ProcessAddEmployerForm()
public IActionResult ProcessAddEmployerForm(AddEmployerViewModel addEmployerViewModel)
{
return View();
if (ModelState.IsValid)
{

Employer theEmployer = new Employer
{
Name = addEmployerViewModel.Name,
Location = addEmployerViewModel.Location
};

_repo.AddNewEmployer(theEmployer);
_repo.SaveChanges();

return Redirect("/Employer");

}


return View("Add", addEmployerViewModel);
}

public IActionResult About(int id)
{
return View();
Employer theEmployer = _repo.FindEmployerById(id);



return View(theEmployer);
}
}
}
Expand Down
40 changes: 37 additions & 3 deletions TechJobsPersistentAutograded/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,69 @@ public class HomeController : Controller
{
private JobRepository _repo;


public HomeController(JobRepository repo)
{
_repo = repo;

}

public IActionResult Index()

{
IEnumerable<Job> jobs = _repo.GetAllJobs();


return View(jobs);
}


[HttpGet("/Add")]
public IActionResult AddJob()
{
return View();
List<Employer> employers = _repo.GetAllEmployers().ToList();
List<Skill> skills = _repo.GetAllSkills().ToList();

AddJobViewModel addJobViewModel = new AddJobViewModel(employers, skills);

return View(addJobViewModel);
}


public IActionResult ProcessAddJobForm()

public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
{

if (ModelState.IsValid)
{

Job theJob = new Job
{
Name = addJobViewModel.Name,
EmployerId = addJobViewModel.EmployerId
};

foreach(var skill in selectedSkills)
{

JobSkill theJobSkill = new JobSkill
{
Job = theJob,
SkillId = Int32.Parse(skill)
};

_repo.AddNewJobSkill(theJobSkill);

}


_repo.AddNewJob(theJob);
_repo.SaveChanges();

return Redirect("Index");
}

return View("Add");
return View("Add", addJobViewModel);
}


Expand Down
1 change: 1 addition & 0 deletions TechJobsPersistentAutograded/Data/JobRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public virtual Employer FindEmployerById(int id)
return _context.Employers.Find(id);
}


public virtual void AddNewEmployer(Employer newEmployer)
{
_context.Employers.Add(newEmployer);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading