Skip to content

Commit 2f95882

Browse files
committed
added application controller
1 parent cf5d028 commit 2f95882

8 files changed

Lines changed: 215 additions & 12 deletions

File tree

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
1-
namespace HRManagementSystem.UI.Controllers
1+
using HRManagementSystem.Business.Interfaces;
2+
using HRManagementSystem.Dtos;
3+
using HRManagementSystem.UI.Extensions;
4+
using Microsoft.AspNetCore.Authorization;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace HRManagementSystem.UI.Controllers
28
{
3-
public class ApplicationController
9+
[Authorize(Roles = "Admin")]
10+
public class ApplicationController : Controller
411
{
12+
private readonly IAdvertisementService _advertisementService;
13+
14+
public ApplicationController(IAdvertisementService advertisementService)
15+
{
16+
_advertisementService = advertisementService;
17+
}
18+
19+
public async Task<IActionResult> List()
20+
{
21+
var response = await _advertisementService.GetAllAsync();
22+
return this.ResponseView(response);
23+
}
24+
25+
public IActionResult Create()
26+
{
27+
return View(new AdvertisementCreateDto());
28+
}
29+
30+
31+
[HttpPost]
32+
public async Task<IActionResult> Create(AdvertisementCreateDto dto)
33+
{
34+
var response = await _advertisementService.CreateAsync(dto);
35+
return this.ResponseRedirectAction(response, "List");
36+
}
37+
38+
public async Task<IActionResult> Update(int id)
39+
{
40+
var response = await _advertisementService.GetByIdAsync<AdvertisementUpdateDto>(id);
41+
return this.ResponseView(response);
42+
}
43+
44+
[HttpPost]
45+
public async Task<IActionResult> Update(AdvertisementUpdateDto dto)
46+
{
47+
var response = await _advertisementService.UpdateAsync(dto);
48+
return this.ResponseRedirectAction(response, "List");
49+
}
50+
51+
public async Task<IActionResult> Remove(int id)
52+
{
53+
var response = await _advertisementService.RemoveAsync(id);
54+
return this.ResponseRedirectAction(response, "List");
55+
}
56+
557
}
658
}

HRManagementSystem.UI/Extensions/ControllerExtensions.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ public static IActionResult ResponseView<T>(this Controller controller, IRespons
4242
return controller.View(response.Data);
4343
}
4444

45-
public static IActionResult ResponseRedirectToAction(this Controller controller, IResponse response, string actionName)
45+
public static IActionResult ResponseRedirectAction(this Controller controller, IResponse response, string actionName)
4646
{
4747
if (response.ResponseType == ResponseType.NotFound)
48-
{
4948
return controller.NotFound();
50-
}
5149
return controller.RedirectToAction(actionName);
5250
}
5351

HRManagementSystem.UI/Views/Advertisement/List.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{
1212
<div class="text-end my-3">
1313
<a asp-action="ApprovedList" asp-controller="Advertisement">Applications invited for interview</a>
14-
<a asp-action="RejectedList" asp-asp-controller="Advertisement">Rejected Application</a>
14+
<a asp-action="RejectedList" asp-controller="Advertisement">Rejected Application</a>
1515
</div>
1616
<table class="table mt-3 table-sm table-hover table-striped">
1717
<thead>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@model AdvertisementCreateDto
2+
3+
@{
4+
ViewData["Title"] = "Create";
5+
Layout = "~/Views/Shared/_Layout.cshtml";
6+
}
7+
8+
<div class="container-fluid">
9+
<form asp-action="Create" asp-controller="Application" method="post">
10+
<div class="mb-3">
11+
<label>Advertisement Title</label>
12+
<input class="form-control" asp-for="@Model.Title" />
13+
</div>
14+
15+
<div class="mb-3 form-check">
16+
<input type="checkbox" class="form-check-input me-2" asp-for="Status" />
17+
<label class="form-check-label" asp-for="Status">Active</label>
18+
</div>
19+
20+
<div class="mb-3">
21+
<label>Content</label>
22+
<textarea asp-for="@Model.Description" class="form-control"></textarea>
23+
</div>
24+
25+
<div class="mb-3">
26+
<button class="btn btn-primary">Save</button>
27+
</div>
28+
</form>
29+
30+
</div>
31+
32+
@section script {
33+
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
34+
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>
35+
<script src="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.27.3/trumbowyg.min.js" integrity="sha512-YJgZG+6o3xSc0k5wv774GS+W1gx0vuSI/kr0E0UylL/Qg/noNspPtYwHPN9q6n59CTR/uhgXfjDXLTRI+uIryg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
36+
<script>
37+
$(document).ready(function () {
38+
$("#Description").trumbowyg({
39+
lang: 'tr'
40+
});
41+
})
42+
</script>
43+
}
44+
45+
@section css {
46+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.27.3/ui/trumbowyg.min.css" integrity="sha512-Fm8kRNVGCBZn0sPmwJbVXlqfJmPC13zRsMElZenX6v721g/H7OukJd8XzDEBRQ2FSATK8xNF9UYvzsCtUpfeJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
47+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@model List<AdvertisementListDto>
2+
3+
@{
4+
ViewData["Title"] = "List";
5+
Layout = "~/Views/Shared/_Layout.cshtml";
6+
}
7+
<div class="container-fluid">
8+
@{
9+
10+
if (Model?.Count > 0)
11+
{
12+
<div class="text-end my-3">
13+
<a asp-action="Create" asp-controller="Application">New Application</a>
14+
</div>
15+
<table class="table mt-3 table-sm table-hover table-striped">
16+
<thead>
17+
<tr>
18+
<th>Advertisement Name</th>
19+
<th>Created Date</th>
20+
<th>Application Status</th>
21+
<th>Process</th>
22+
</thead>
23+
<tbody>
24+
@foreach (var advertisement in Model)
25+
{
26+
<tr>
27+
<td>@advertisement.Title</td>
28+
<td>@advertisement.CreatedDate.ToString("dddd,dd MMMM yyyy")</td>
29+
<td>@(advertisement.Status == true ? "Active" : "Passive")</td>
30+
<td>
31+
<a asp-action="Update" asp-controller="Application" asp-route-id="@advertisement.Id">Update</a>
32+
<a asp-action="Remove" asp-controller="Application" asp-route-id="@advertisement.Id">Remove</a>
33+
</td>
34+
</tr>
35+
36+
}
37+
</tbody>
38+
</table>
39+
}
40+
else
41+
{
42+
<div class="text-end my-3">
43+
<a asp-action="Create" asp-asp-controller="Application">New Application</a>
44+
</div>
45+
46+
<div class="mt-3 text-center lead">
47+
There is no advertisement!
48+
</div>
49+
}
50+
}
51+
</div>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@model AdvertisementUpdateDto
2+
3+
@{
4+
ViewData["Title"] = "Update";
5+
Layout = "~/Views/Shared/_Layout.cshtml";
6+
}
7+
8+
<div class="container-fluid">
9+
<form asp-action="Update" asp-controller="Application" method="post">
10+
<input type="hidden" asp-for="@Model.Id" />
11+
<div class="mb-3">
12+
<label>Advertisement Title</label>
13+
<input class="form-control" asp-for="@Model.Title" />
14+
</div>
15+
16+
<div class="mb-3 form-check">
17+
<input type="checkbox" class="form-check-input me-2" asp-for="Status" />
18+
<label class="form-check-label" asp-for="Status">Active</label>
19+
</div>
20+
21+
<div class="mb-3">
22+
<label>Content</label>
23+
<textarea asp-for="@Model.Description" class="form-control"></textarea>
24+
</div>
25+
26+
<div class="mb-3">
27+
<button class="btn btn-primary">Save</button>
28+
</div>
29+
</form>
30+
31+
</div>
32+
33+
@section script {
34+
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
35+
<script>window.jQuery || document.write('<script src="js/vendor/jquery-3.3.1.min.js"><\/script>')</script>
36+
<script src="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.27.3/trumbowyg.min.js" integrity="sha512-YJgZG+6o3xSc0k5wv774GS+W1gx0vuSI/kr0E0UylL/Qg/noNspPtYwHPN9q6n59CTR/uhgXfjDXLTRI+uIryg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
37+
<script>
38+
$(document).ready(function () {
39+
$("#Description").trumbowyg({
40+
lang: 'tr'
41+
});
42+
})
43+
</script>
44+
}
45+
46+
@section css {
47+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.27.3/ui/trumbowyg.min.css" integrity="sha512-Fm8kRNVGCBZn0sPmwJbVXlqfJmPC13zRsMElZenX6v721g/H7OukJd8XzDEBRQ2FSATK8xNF9UYvzsCtUpfeJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
48+
}

HRManagementSystem.UI/Views/Home/HumanResources.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</h2>
1414
<div id="collapse-@Model[i].Id" class="accordion-collapse collapse @(i == 0 ? "show" : "")" aria-labelledby="heading-@Model[i].Id" data-bs-parent="#accordionExample">
1515
<div class="accordion-body">
16-
@Model[i].Description
16+
Html.Raw(@Model[i].Description)
1717

1818
@if (User.Identity.IsAuthenticated)
1919
{

HRManagementSystem.UI/Views/Shared/_Layout.cshtml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<link href="~/focusadmintemplate/css/style.css" rel="stylesheet" />
1515
<link href="~/css/style.css" rel="stylesheet" />
1616
<link href="~/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
17+
18+
@RenderSection("css", false)
1719
</head>
1820

1921
<body>
@@ -76,7 +78,7 @@
7678
{
7779
<li>
7880
<a asp-action="HumanResources" asp-controller="Home" aria-expanded="false">
79-
<i class="fa-brands fa-osi"></i><span class="nav-text">Human Resources</span>
81+
<i class="fa-brands fa-web-awesome"></i><span class="nav-text">Human Resources</span>
8082
</a>
8183
</li>
8284
}
@@ -85,13 +87,19 @@
8587
{
8688
<li>
8789
<a asp-action="List" asp-controller="Advertisement" aria-expanded="false">
88-
<i class="fa-brands fa-osi"></i><span class="nav-text">Job Adverts</span>
90+
<i class="fa-brands fa-uikit"></i><span class="nav-text">Applications</span>
91+
</a>
92+
</li>
93+
94+
<li>
95+
<a asp-action="List" asp-controller="Application" aria-expanded="false">
96+
<i class="fa-brands fa-space-awesome"></i><span class="nav-text">Job Adverts</span>
8997
</a>
9098
</li>
9199
}
92100
<li>
93101
<a asp-action="LogOut" asp-controller="Account" aria-expanded="false">
94-
<i class="fa-brands fa-osi"></i><span class="nav-text">LogOut</span>
102+
<i class="fa-solid fa-right-from-bracket"></i><span class="nav-text">Log Out</span>
95103
</a>
96104
</li>
97105

@@ -111,10 +119,9 @@
111119

112120
<li>
113121
<a asp-action="HumanResources" asp-controller="Home" aria-expanded="false">
114-
<i class="fa-solid fa-right-to-bracket"></i><span class="nav-text">Human Resources</span>
122+
<i class="fa-solid fa-person"></i><span class="nav-text">Human Resources</span>
115123
</a>
116124
</li>
117-
118125
}
119126
}
120127
</ul>

0 commit comments

Comments
 (0)