-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into issue_52-pantalla-perfil
- Loading branch information
Showing
12 changed files
with
264 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,77 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Mvc; | ||
using AppServices; | ||
using AppServices.Services; | ||
using Web.ViewModels; | ||
|
||
namespace Web.Controllers | ||
{ | ||
public class JobsController : Controller | ||
using System; | ||
using Microsoft.AspNetCore.Mvc; | ||
using AppServices; | ||
using AppServices.Services; | ||
using Web.ViewModels; | ||
using Domain; | ||
|
||
namespace Web.Controllers | ||
{ | ||
public class JobsController : Controller | ||
{ | ||
private IJobsService _jobsService; | ||
|
||
public JobsController() | ||
{ | ||
_jobsService = new JobsService(); | ||
public JobsController() | ||
{ | ||
_jobsService = new JobsService(); | ||
} | ||
|
||
public IActionResult Index(string keyword = "", bool isRemote = false) | ||
{ | ||
var filteredJobs = _jobsService.GetAll(); | ||
var viewModel = new JobsViewModel | ||
{ | ||
Keyword = keyword, | ||
IsRemote = isRemote, | ||
Jobs = filteredJobs | ||
var filteredJobs = _jobsService.GetAll(); | ||
var viewModel = new JobsViewModel | ||
{ | ||
Keyword = keyword, | ||
IsRemote = isRemote, | ||
Jobs = filteredJobs | ||
}; | ||
return View(viewModel); | ||
} | ||
|
||
|
||
public IActionResult Details() | ||
} | ||
|
||
|
||
public IActionResult Details(string Id, bool isPreview) | ||
{ | ||
return View(); | ||
} | ||
} | ||
} | ||
|
||
if (String.IsNullOrEmpty(Id)) | ||
return RedirectToAction(nameof(this.Index)); | ||
|
||
|
||
int jobId = this.GetJobIdFromTitle(Id); | ||
|
||
if (jobId == 0) | ||
return RedirectToAction(nameof(this.Index)); | ||
|
||
var job = this._jobsService.GetDetails(jobId, isPreview); | ||
|
||
//Manage error message | ||
if (job == null) | ||
return RedirectToAction(nameof(this.Index)); | ||
|
||
//If reach this line is because the job exists | ||
var viewModel = new JobsViewModel | ||
{ | ||
Job = job | ||
}; | ||
|
||
if (isPreview) | ||
{ | ||
viewModel.IsPreview = isPreview; | ||
return View(viewModel); | ||
} | ||
|
||
|
||
|
||
return View(viewModel); | ||
} | ||
|
||
|
||
private int GetJobIdFromTitle(string title) | ||
{ | ||
var url = title.Split('-'); | ||
if (String.IsNullOrEmpty(title) || title.Length == 0 || !int.TryParse(url[0], out int id)) | ||
return 0; | ||
return id; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Domain; | ||
|
||
namespace Web.ViewModels | ||
{ | ||
public class HomeViewModel | ||
public class HomeViewModel : BaseViewModel | ||
{ | ||
public HomeViewModel() | ||
{ | ||
} | ||
public IEnumerable<Job> Jobs { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.