-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
827 additions
and
149 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using EntityLayer.Concrete; | ||
|
||
namespace BlogWeb.Areas.Admin.Models | ||
{ | ||
public class UserViewModel | ||
{ | ||
public User User { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using EntityLayer.Concrete; | ||
using System.Collections.Generic; | ||
|
||
namespace BlogWeb.Areas.Admin.Models | ||
{ | ||
public class UserWithRolesViewModel | ||
{ | ||
//Bu bölüm, yetkisiz kullanicilarin yetkisi olmayan bölümleri görmemesini saglar | ||
public User User { get; set; } | ||
public IList<string> Roles { get; set; } | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
BlogWeb/Areas/Admin/ViewComponents/AdminMenuViewComponent.cs
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using BlogWeb.Areas.Admin.Models; | ||
using EntityLayer.Concrete; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.ViewComponents; | ||
|
||
namespace BlogWeb.Areas.Admin.ViewComponents | ||
{ | ||
public class AdminMenuViewComponent:ViewComponent | ||
{ | ||
private readonly UserManager<User> _userManager; | ||
|
||
public AdminMenuViewComponent(UserManager<User> userManager) | ||
{ | ||
_userManager = userManager; | ||
} | ||
|
||
public ViewViewComponentResult Invoke() | ||
{ | ||
var user = _userManager.GetUserAsync(HttpContext.User).Result; | ||
var roles = _userManager.GetRolesAsync(user).Result; | ||
|
||
return View(new UserWithRolesViewModel | ||
{ | ||
User = user, | ||
Roles = roles | ||
}); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
BlogWeb/Areas/Admin/ViewComponents/UserMenuViewComponent.cs
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using BlogWeb.Areas.Admin.Models; | ||
using EntityLayer.Concrete; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.ViewComponents; | ||
|
||
namespace BlogWeb.Areas.Admin.ViewComponents | ||
{ | ||
public class UserMenuViewComponent:ViewComponent | ||
{ | ||
private readonly UserManager<User> _userManager; | ||
|
||
public UserMenuViewComponent(UserManager<User> userManager) | ||
{ | ||
_userManager = userManager; | ||
} | ||
|
||
public ViewViewComponentResult Invoke() | ||
{ | ||
var user = _userManager.GetUserAsync(HttpContext.User).Result; | ||
return View(new UserViewModel | ||
{ | ||
User = user | ||
}); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
BlogWeb/Areas/Admin/Views/Shared/Components/AdminMenu/Default.cshtml
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@model BlogWeb.Areas.Admin.Models.UserWithRolesViewModel | ||
|
||
<div id="layoutSidenav_nav"> | ||
<nav class="sb-sidenav accordion sb-sidenav-dark" id="sidenavAccordion"> | ||
<div class="sb-sidenav-menu"> | ||
<div class="nav"> | ||
<div class="sb-sidenav-menu-heading">MENÜ</div> | ||
<a class="nav-link" asp-area="Admin" asp-controller="Home" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-tachometer-alt"></i></div> | ||
Dashboard | ||
</a> | ||
<div class="sb-sidenav-menu-heading">İçerikler</div> | ||
<a class="nav-link" asp-area="Admin" asp-controller="Category" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-th-list"></i></div> | ||
Kategoriler | ||
</a> | ||
<a class="nav-link" asp-area="Admin" asp-controller="Blog" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-file-alt"></i></div> | ||
Makaleler | ||
</a> | ||
<a class="nav-link" asp-area="Admin" asp-controller="Comment" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-comments"></i></div> | ||
Yorumlar | ||
</a> | ||
@if (Model.Roles.Any(r=>r.Equals("Admin"))) | ||
{ | ||
<div class="sb-sidenav-menu-heading">Kullanıcılar</div> | ||
<a class="nav-link" asp-area="Admin" asp-controller="Role" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-user-shield"></i></div> | ||
Roller | ||
</a> | ||
<a class="nav-link" asp-area="Admin" asp-controller="User" asp-action="Index"> | ||
<div class="sb-nav-link-icon"><i class="fas fa-users"></i></div> | ||
Kullanıcılar | ||
</a> | ||
} | ||
</div> | ||
</div> | ||
<div class="sb-sidenav-footer"> | ||
<div class="small">Giriş Yapan Kullanıcı:</div> | ||
@Model.User.UserName | ||
</div> | ||
</nav> | ||
</div> |
Oops, something went wrong.